@content-island/vscode-api-client 0.2.4 → 0.2.5
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.
- package/dist/index.d.ts +45 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -21,6 +21,14 @@ declare interface ApiClient {
|
|
|
21
21
|
* the loader on a missing/unreadable/invalid file.
|
|
22
22
|
*/
|
|
23
23
|
getSnapshotInfo: () => Promise<SnapshotMeta>;
|
|
24
|
+
/**
|
|
25
|
+
* Pulls a fresh snapshot via the configured `snapshotLoader`, validates and guards it, and atomically
|
|
26
|
+
* swaps the active snapshot when the incoming one is newer. Returns `{ status: 'updated', meta }` on
|
|
27
|
+
* adoption or `{ status: 'unchanged', meta }` when the anti-regression guard retains the current one.
|
|
28
|
+
* Throws `ApiClientError` in `'api'` mode, without a configured `snapshotLoader`, or on a
|
|
29
|
+
* loader/validation/identity failure (the active snapshot is left untouched).
|
|
30
|
+
*/
|
|
31
|
+
refreshSnapshot: () => Promise<SnapshotRefreshResult>;
|
|
24
32
|
/**
|
|
25
33
|
* Updates (or upserts, when selected by `fieldName`+`language`) a field value on an existing content.
|
|
26
34
|
*
|
|
@@ -85,6 +93,17 @@ export declare type ContentListSizeQueryParams<M extends Model = Model & Record<
|
|
|
85
93
|
|
|
86
94
|
export declare type ContentQueryParams<M extends Model = Model & Record<string, any>> = Omit<QueryParams<M>, 'sort' | 'pagination'>;
|
|
87
95
|
|
|
96
|
+
/**
|
|
97
|
+
* The full content snapshot document produced by `GET /project/export` and consumed
|
|
98
|
+
* by the api-client in static mode. `contents` is serialized in the existing API
|
|
99
|
+
* `Content` shape at related-content depth 0.
|
|
100
|
+
*/
|
|
101
|
+
declare interface ContentSnapshot {
|
|
102
|
+
meta: SnapshotMeta;
|
|
103
|
+
project: Project;
|
|
104
|
+
contents: Content[];
|
|
105
|
+
}
|
|
106
|
+
|
|
88
107
|
declare interface ContentTypeField extends Lookup {
|
|
89
108
|
type: FieldType;
|
|
90
109
|
tsType: string;
|
|
@@ -445,6 +464,13 @@ declare interface Options {
|
|
|
445
464
|
* invalid file at the resolved path rejects with an `ApiClientError` from the loader.
|
|
446
465
|
*/
|
|
447
466
|
snapshotPath?: string;
|
|
467
|
+
/**
|
|
468
|
+
* Optional loader for a refreshable snapshot in `'snapshot'` mode. When set without `snapshotPath`
|
|
469
|
+
* (loader-only), the client resolves the active snapshot via the loader on first read. Required for
|
|
470
|
+
* `refreshSnapshot()`; calling `refreshSnapshot()` without it throws an `ApiClientError`. A
|
|
471
|
+
* `snapshotPath`-only client (no loader) keeps the static 0.1.0 behavior.
|
|
472
|
+
*/
|
|
473
|
+
snapshotLoader?: SnapshotLoader;
|
|
448
474
|
}
|
|
449
475
|
|
|
450
476
|
declare type Pagination = {
|
|
@@ -491,6 +517,14 @@ declare interface SaveModelResponse {
|
|
|
491
517
|
id: string;
|
|
492
518
|
}
|
|
493
519
|
|
|
520
|
+
/**
|
|
521
|
+
* User-provided fetch for a refreshable snapshot. Opaque to the core: it may read a blob/S3/file or
|
|
522
|
+
* call `exportSnapshot()`. Returns either raw snapshot JSON text (which the client `JSON.parse`s) or
|
|
523
|
+
* an already-parsed `ContentSnapshot` object (passed through as-is). Invoked only on the first read in
|
|
524
|
+
* the loader-only case and on `refreshSnapshot()` — never during `createClient` construction.
|
|
525
|
+
*/
|
|
526
|
+
declare type SnapshotLoader = () => Promise<string | ContentSnapshot>;
|
|
527
|
+
|
|
494
528
|
declare interface SnapshotMeta {
|
|
495
529
|
schemaVersion: number;
|
|
496
530
|
/** ISO-8601 timestamp of when the snapshot was generated on the server. */
|
|
@@ -499,6 +533,16 @@ declare interface SnapshotMeta {
|
|
|
499
533
|
view: 'published' | 'preview';
|
|
500
534
|
}
|
|
501
535
|
|
|
536
|
+
/**
|
|
537
|
+
* Outcome of a `refreshSnapshot()` call. `'updated'` when the incoming snapshot was adopted as the new
|
|
538
|
+
* active snapshot (its `meta` is returned); `'unchanged'` when the anti-regression guard kept the
|
|
539
|
+
* current active snapshot (the retained snapshot's `meta` is returned).
|
|
540
|
+
*/
|
|
541
|
+
declare type SnapshotRefreshResult = {
|
|
542
|
+
status: 'updated' | 'unchanged';
|
|
543
|
+
meta: SnapshotMeta;
|
|
544
|
+
};
|
|
545
|
+
|
|
502
546
|
declare type SortableFields<M extends Model> = {
|
|
503
547
|
contentType?: SortOrder;
|
|
504
548
|
lastUpdate?: SortOrder;
|
|
@@ -519,7 +563,7 @@ declare interface UploadMediaParams {
|
|
|
519
563
|
|
|
520
564
|
declare type Validation = { name: string; customArgs?: any };
|
|
521
565
|
|
|
522
|
-
export declare interface VSCodeApiClient extends Omit<ApiClient, 'createModel' | 'updateModel' | 'deleteModel' | 'createEnum' | 'updateEnum' | 'deleteEnum'> {
|
|
566
|
+
export declare interface VSCodeApiClient extends Omit<ApiClient, 'createModel' | 'updateModel' | 'deleteModel' | 'createEnum' | 'updateEnum' | 'deleteEnum' | 'refreshSnapshot'> {
|
|
523
567
|
setVSCodeExtensionContext: (context: vscode.ExtensionContext) => void;
|
|
524
568
|
authorize: (authorizationCode: string, metadata: string) => Promise<void>;
|
|
525
569
|
authorizeByProjectId: (projectId: string) => Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@content-island/vscode-api-client",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "Content Island - VSCode Extension API Client",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"test:watch": "vitest -c ./config/test/config.ts"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@content-island/api-client": "0.
|
|
35
|
+
"@content-island/api-client": "0.24.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@content-island/common-backend": "*",
|