Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update api context to match shopware administration #369

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/dirty-pumpkins-cheat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@shopware-ag/meteor-admin-sdk": patch
---

Update api context to match shopware administration
32 changes: 8 additions & 24 deletions packages/admin-sdk/src/_internals/data/EntityCollection.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,20 @@
import Criteria from '../../data/Criteria';
import type { Entity } from './Entity';
import type { ApiContext } from '../../context';

type ApiAuthToken = {
access: string,
expiry: number,
refresh: string,
}
/**
* @deprecated Use {@link ApiContext} instead.
*/
interface DeprecatedApiContext extends ApiContext {};

export type { DeprecatedApiContext as ApiContext };

type Aggregations = {
[key: string]: {
name: string,
[key: string]: unknown,
},
}

export interface ApiContext {
apiPath: null | string,
apiResourcePath: null | string,
assetsPath: null | string,
authToken: null | ApiAuthToken,
basePath: null | string,
pathInfo: null | string,
inheritance: null | boolean,
installationPath: null | string,
languageId: null | string,
language: null | {
name: string,
},
apiVersion: null | string,
liveVersionId: null | string,
systemLanguageId: null | string,
}
};

type Entities = EntitySchema.Entities;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import EntityCollection, {ApiContext} from '../data/EntityCollection';
import EntityCollection from '../data/EntityCollection';
import Criteria from '../../data/Criteria';
import Entity from '../data/Entity';
import SerializerFactory from './index';
import { handle, send } from '../../channel';
import type { ApiContext } from '../../context';
import Vue from 'vue';

const { serialize, deserialize } = SerializerFactory({
Expand Down
27 changes: 27 additions & 0 deletions packages/admin-sdk/src/context/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
import { createSender, createSubscriber } from '../channel';

export type ApiAuthToken = {
access: string,
expiry: number,
refresh: string,
}

export interface ApiContext {
apiPath: null | string,
apiResourcePath: null | string,
assetsPath: null | string,
authToken: null | ApiAuthToken,
basePath: null | string,
pathInfo: null | string,
inheritance: null | boolean,
installationPath: null | string,
languageId: null | string,
language: null | {
name: string,
parentId?: string,
},
apiVersion: null | string,
liveVersionId: null | string,
systemLanguageId: null | string,
currencyId: null | string,
versionId: null | string,
}

export const getLanguage = createSender('contextLanguage', {});
export const subscribeLanguage = createSubscriber('contextLanguage');
export const getEnvironment = createSender('contextEnvironment', {});
Expand Down
2 changes: 1 addition & 1 deletion packages/admin-sdk/src/data/repository.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { send } from '../channel';
import type Criteria from './Criteria';
import type { ApiContext } from '../_internals/data/EntityCollection';
import type { ApiContext } from '../context';
import type EntityCollection from '../_internals/data/EntityCollection';
import type { Entity } from '../_internals/data/Entity';

Expand Down