@contello/store 1.3.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,9 @@
1
+ /**
2
+ * resolved absolute paths to the `.gql` fragment files that store-backed
3
+ * codegen should include. combines media's primitives with store's own
4
+ * `StoreAsset` / `StoreRoute` fragments. intended for use in a project's
5
+ * codegen `documents` config.
6
+ */
7
+ declare const fragments: string[];
8
+
9
+ export { fragments };
@@ -0,0 +1,12 @@
1
+ // src/fragments.ts
2
+ import { fileURLToPath } from "url";
3
+ import { fragments as mediaFragments } from "@contello/media/fragments";
4
+ var packageRoot = fileURLToPath(new URL("..", import.meta.url));
5
+ var fragments = [
6
+ ...mediaFragments,
7
+ `${packageRoot}fragments/asset.gql`,
8
+ `${packageRoot}fragments/route.gql`
9
+ ];
10
+ export {
11
+ fragments
12
+ };
package/dist/index.cjs CHANGED
@@ -37,6 +37,7 @@ module.exports = __toCommonJS(index_exports);
37
37
 
38
38
  // src/store.ts
39
39
  var import_client = require("@contello/client");
40
+ var import_media = require("@contello/media");
40
41
 
41
42
  // src/assets.ts
42
43
  var import_projected = require("projected");
@@ -1299,6 +1300,7 @@ var Store = class {
1299
1300
  _resolver;
1300
1301
  _watcher;
1301
1302
  updates$;
1303
+ media;
1302
1304
  constructor(options) {
1303
1305
  const { url, project, token, operations } = options;
1304
1306
  this._client = (0, import_client.createContelloClient)({
@@ -1315,6 +1317,7 @@ var Store = class {
1315
1317
  this._resolver = new ModelResolver(options.models);
1316
1318
  this._watcher = createInternalWatcher(this._client, this._resolver);
1317
1319
  this.updates$ = this._watcher.updates$;
1320
+ this.media = (0, import_media.createMediaResolver)(options.media ?? {});
1318
1321
  this.ping = () => this._client.ping();
1319
1322
  }
1320
1323
  async init() {
package/dist/index.d.cts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { OperationMap, ContelloClient, ConnectionEvents, UploadData, UploadMetadata, UploadOptions, DownloadResult, ProxyResult } from '@contello/client';
2
+ import { MediaResolverOptions, MediaResolver } from '@contello/media';
2
3
  import { Observable } from 'rxjs';
3
4
  import { MaybePromise } from 'projected';
4
5
 
@@ -112,6 +113,7 @@ type CreateStoreOptions<TOps extends OperationMap | undefined = undefined, TMode
112
113
  onReconnecting?: (() => void) | undefined;
113
114
  onError?: ((error: unknown) => void) | undefined;
114
115
  connectionEvents?: ConnectionEvents | undefined;
116
+ media?: MediaResolverOptions | undefined;
115
117
  };
116
118
  /** Cache options for non-lazy collections and singletons. */
117
119
  type CacheOptions = {
@@ -316,6 +318,7 @@ declare class Store<TOps extends OperationMap | undefined = undefined, TModels e
316
318
  private _resolver;
317
319
  private _watcher;
318
320
  readonly updates$: Observable<UpdateBatch>;
321
+ readonly media: MediaResolver;
319
322
  constructor(options: CreateStoreOptions<TOps, TModels>);
320
323
  init(): Promise<void>;
321
324
  destroy(): Promise<void>;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { OperationMap, ContelloClient, ConnectionEvents, UploadData, UploadMetadata, UploadOptions, DownloadResult, ProxyResult } from '@contello/client';
2
+ import { MediaResolverOptions, MediaResolver } from '@contello/media';
2
3
  import { Observable } from 'rxjs';
3
4
  import { MaybePromise } from 'projected';
4
5
 
@@ -112,6 +113,7 @@ type CreateStoreOptions<TOps extends OperationMap | undefined = undefined, TMode
112
113
  onReconnecting?: (() => void) | undefined;
113
114
  onError?: ((error: unknown) => void) | undefined;
114
115
  connectionEvents?: ConnectionEvents | undefined;
116
+ media?: MediaResolverOptions | undefined;
115
117
  };
116
118
  /** Cache options for non-lazy collections and singletons. */
117
119
  type CacheOptions = {
@@ -316,6 +318,7 @@ declare class Store<TOps extends OperationMap | undefined = undefined, TModels e
316
318
  private _resolver;
317
319
  private _watcher;
318
320
  readonly updates$: Observable<UpdateBatch>;
321
+ readonly media: MediaResolver;
319
322
  constructor(options: CreateStoreOptions<TOps, TModels>);
320
323
  init(): Promise<void>;
321
324
  destroy(): Promise<void>;
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  // src/store.ts
2
2
  import { createContelloClient } from "@contello/client";
3
+ import { createMediaResolver } from "@contello/media";
3
4
 
4
5
  // src/assets.ts
5
6
  import { ProjectedLazyMap } from "projected";
@@ -1262,6 +1263,7 @@ var Store = class {
1262
1263
  _resolver;
1263
1264
  _watcher;
1264
1265
  updates$;
1266
+ media;
1265
1267
  constructor(options) {
1266
1268
  const { url, project, token, operations } = options;
1267
1269
  this._client = createContelloClient({
@@ -1278,6 +1280,7 @@ var Store = class {
1278
1280
  this._resolver = new ModelResolver(options.models);
1279
1281
  this._watcher = createInternalWatcher(this._client, this._resolver);
1280
1282
  this.updates$ = this._watcher.updates$;
1283
+ this.media = createMediaResolver(options.media ?? {});
1281
1284
  this.ping = () => this._client.ping();
1282
1285
  }
1283
1286
  async init() {
@@ -1,27 +1,7 @@
1
1
  fragment StoreFile on ContelloFile {
2
- uid
3
- mimeType
4
- metadata {
5
- ... on ContelloImageMetadata {
6
- width
7
- height
8
- }
9
- ... on ContelloVideoMetadata {
10
- width
11
- height
12
- }
13
- }
2
+ ...MediaFile
14
3
  }
15
4
 
16
5
  fragment StoreAsset on ContelloAsset {
17
- id
18
- original {
19
- ...StoreFile
20
- }
21
- preview {
22
- ...StoreFile
23
- }
24
- optimized {
25
- ...StoreFile
26
- }
6
+ ...MediaAsset
27
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contello/store",
3
- "version": "1.3.0",
3
+ "version": "1.4.1",
4
4
  "description": "Framework-agnostic store for Contello CMS with reactive collections and automatic dependency tracking",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -17,7 +17,8 @@
17
17
  "dependencies": {
18
18
  "backoff-rxjs": "^7.0.0",
19
19
  "lru-cache": "^11.3.5",
20
- "@contello/client": "^1.1.0"
20
+ "@contello/client": "^1.1.0",
21
+ "@contello/media": "^1.0.0"
21
22
  },
22
23
  "devDependencies": {
23
24
  "projected": "^2.2.1",
@@ -32,6 +33,10 @@
32
33
  ".": {
33
34
  "import": "./dist/index.js",
34
35
  "require": "./dist/index.cjs"
36
+ },
37
+ "./fragments": {
38
+ "import": "./dist/fragments.js",
39
+ "types": "./dist/fragments.d.ts"
35
40
  }
36
41
  },
37
42
  "publishConfig": {