Skip to content

Commit

Permalink
Update api context to match shopware administration
Browse files Browse the repository at this point in the history
  • Loading branch information
akf-bw committed Nov 12, 2024
1 parent 0706052 commit 31768f4
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 26 deletions.
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

0 comments on commit 31768f4

Please sign in to comment.