@stackbit/cms-core 3.1.11 → 3.1.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackbit/cms-core",
3
- "version": "3.1.11",
3
+ "version": "3.1.12",
4
4
  "description": "stackbit-dev",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -26,10 +26,9 @@
26
26
  "@babel/traverse": "^7.11.5",
27
27
  "@iarna/toml": "^2.2.3",
28
28
  "@netlify/content-engine": "^1.4.0",
29
- "@netlify/sdk": "^1.17.2",
30
- "@stackbit/sdk": "2.1.8",
31
- "@stackbit/types": "2.1.5",
32
- "@stackbit/utils": "0.7.7",
29
+ "@stackbit/sdk": "2.1.9",
30
+ "@stackbit/types": "2.1.6",
31
+ "@stackbit/utils": "0.7.8",
33
32
  "chalk": "^4.0.1",
34
33
  "esm": "^3.2.25",
35
34
  "fs-extra": "^8.1.0",
@@ -44,5 +43,5 @@
44
43
  "slugify": "^1.6.5",
45
44
  "uuid": "^9.0.0"
46
45
  },
47
- "gitHead": "e2b34041d6e9a0ce3818c1976288d296f23b52f8"
46
+ "gitHead": "303573fa07256b72701e84cd2854734efa703155"
48
47
  }
@@ -485,16 +485,6 @@ export class ContentStore {
485
485
 
486
486
  if (init) {
487
487
  this.logger.debug('init content sources');
488
- if (this.stackbitConfig?.connectors) {
489
- const contentSources = this.contentSources || [];
490
- if (this.stackbitConfig?.connectors?.length) {
491
- const ConnectorWrapper = (await import('./connector/connector-wrapper.mjs')).default;
492
- for (const connector of this.stackbitConfig.connectors) {
493
- contentSources.push(new ConnectorWrapper(connector));
494
- }
495
- }
496
- this.contentSources = contentSources;
497
- }
498
488
  await this.createContentEngineIfNeeded();
499
489
  }
500
490
 
@@ -1,111 +0,0 @@
1
- import { NetlifyIntegration } from '@netlify/sdk';
2
- import { Asset, ContentChanges, ContentEngineConfig, ContentSourceInterface, Document, Model, UpdateOperation, UpdateOperationField, UserSSOProfile } from '@stackbit/types';
3
- export default class ConnectorWrapper implements ContentSourceInterface {
4
- private integration;
5
- private options;
6
- private connector;
7
- constructor({ integration, config }: {
8
- integration: NetlifyIntegration;
9
- config: any;
10
- });
11
- getContentSourceType(): string;
12
- getProjectId(): string;
13
- getVersion(): Promise<{
14
- interfaceVersion: string;
15
- contentSourceVersion: string;
16
- }>;
17
- getProjectEnvironment(): string;
18
- getProjectManageUrl(): any;
19
- hasAccess(): Promise<{
20
- hasPermissions: boolean;
21
- hasConnection: boolean;
22
- }>;
23
- validateDocuments(): Promise<{
24
- errors: never[];
25
- }>;
26
- reset(): Promise<void>;
27
- destroy(): Promise<void>;
28
- _getAPIPromises(name: string): Promise<any>;
29
- _getImplementation(name: string): Promise<any>;
30
- init({ cache }: {
31
- cache: any;
32
- }): Promise<void>;
33
- updateDocument(options: {
34
- document: Document<unknown>;
35
- operations: UpdateOperation[];
36
- userContext?: {
37
- name: string;
38
- email: string;
39
- sso?: UserSSOProfile | undefined;
40
- } | undefined;
41
- }): Promise<void>;
42
- createDocument(options: {
43
- updateOperationFields: Record<string, UpdateOperationField>;
44
- model: Model<unknown>;
45
- locale?: string | undefined;
46
- defaultLocaleDocumentId?: string | undefined;
47
- userContext?: {
48
- name: string;
49
- email: string;
50
- sso?: UserSSOProfile | undefined;
51
- } | undefined;
52
- }): Promise<{
53
- documentId: string;
54
- }>;
55
- deleteDocument(options: {
56
- document: Document<unknown>;
57
- userContext?: {
58
- name: string;
59
- email: string;
60
- sso?: UserSSOProfile | undefined;
61
- } | undefined;
62
- }): Promise<void>;
63
- publishDocuments(options: {
64
- documents: Document<unknown>[];
65
- assets: Asset<unknown>[];
66
- userContext?: {
67
- name: string;
68
- email: string;
69
- sso?: UserSSOProfile | undefined;
70
- } | undefined;
71
- }): Promise<void>;
72
- getSchema(): Promise<{
73
- models: any;
74
- locales: any;
75
- context: {};
76
- }>;
77
- getModels(): Promise<any>;
78
- getLocales(): Promise<any>;
79
- connectSyncFinished(): Promise<any>;
80
- getDocuments(): Promise<Document<unknown>[]>;
81
- getAssets(): Promise<Asset<unknown>[]>;
82
- uploadAsset(options: {
83
- url?: string | undefined;
84
- base64?: string | undefined;
85
- fileName: string;
86
- mimeType: string;
87
- locale?: string | undefined;
88
- userContext?: {
89
- name: string;
90
- email: string;
91
- sso?: UserSSOProfile | undefined;
92
- } | undefined;
93
- }): Promise<Asset<unknown>>;
94
- updateAsset(options: {
95
- asset: Asset<unknown>;
96
- operations: UpdateOperation[];
97
- userContext?: {
98
- name: string;
99
- email: string;
100
- sso?: UserSSOProfile | undefined;
101
- } | undefined;
102
- }): Promise<void>;
103
- getContentEngineConfig(): ContentEngineConfig;
104
- onFilesChange({ updatedFiles }: {
105
- updatedFiles: string[];
106
- }): Promise<{
107
- invalidateSchema?: boolean | undefined;
108
- contentChanges?: ContentChanges<unknown, unknown> | undefined;
109
- }>;
110
- }
111
- //# sourceMappingURL=connector-wrapper.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"connector-wrapper.d.mts","sourceRoot":"","sources":["../../src/connector/connector-wrapper.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EACH,KAAK,EACL,cAAc,EACd,mBAAmB,EACnB,sBAAsB,EACtB,QAAQ,EACR,KAAK,EACL,eAAe,EACf,oBAAoB,EACpB,cAAc,EACjB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,CAAC,OAAO,OAAO,gBAAiB,YAAW,sBAAsB;IACnE,OAAO,CAAC,WAAW,CAAqB;IACxC,OAAO,CAAC,OAAO,CAAM;IACrB,OAAO,CAAC,SAAS,CAAM;gBAEX,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE;QAAE,WAAW,EAAE,kBAAkB,CAAC;QAAC,MAAM,EAAE,GAAG,CAAA;KAAE;IAMrF,oBAAoB;IAKpB,YAAY;IAKN,UAAU;;;;IAIhB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K,EAAE,MAAM,CAAC;YAAC,GAAG,CAAC,EAAE,cAAc,GAAG,SAAS,CAAA;SAAE,GAAG,SAAS,CAAC;KAC/F,GAAG,OAAO,CAAC,IAAI,CAAC;IAIjB,sBAAsB,IAAI,mBAAmB;IAYvC,aAAa,CAAC,EAChB,YAAY,EACf,EAAE;QACC,YAAY,EAAE,MAAM,EAAE,CAAC;KAC1B,GAAG,OAAO,CAAC;QAAE,gBAAgB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;QAAC,cAAc,CAAC,EAAE,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,SAAS,CAAA;KAAE,CAAC;CAGzH"}
@@ -1,154 +0,0 @@
1
- export default class ConnectorWrapper {
2
- constructor({ integration, config }) {
3
- this.integration = integration;
4
- this.options = config;
5
- this.connector = integration.netlifyConnectPlugin;
6
- }
7
- getContentSourceType() {
8
- // todo
9
- return 'todo';
10
- }
11
- getProjectId() {
12
- // todo
13
- return '1';
14
- }
15
- async getVersion() {
16
- return { interfaceVersion: '0.7.3', contentSourceVersion: '0.1' };
17
- }
18
- getProjectEnvironment() {
19
- // todo
20
- return 'main';
21
- }
22
- getProjectManageUrl() {
23
- return this.connector._getProjectManageUrl();
24
- }
25
- // todo make these custom error classes to be thrown from within
26
- // sync/create/publish/etc
27
- hasAccess() {
28
- return Promise.resolve({
29
- hasPermissions: true,
30
- hasConnection: true
31
- });
32
- }
33
- validateDocuments() {
34
- return Promise.resolve({ errors: [] });
35
- }
36
- // for now reset/destroy are not needed
37
- reset() {
38
- return Promise.resolve();
39
- }
40
- destroy() {
41
- return Promise.resolve();
42
- }
43
- async _getAPIPromises(name) {
44
- return this.connector.getAPIPromises(name);
45
- }
46
- async _getImplementation(name) {
47
- return this.connector.definedImplementations.get(name);
48
- }
49
- async init({ cache }) {
50
- this.integration.netlifyConnectPlugin?.setRuntimeSupportsCreate();
51
- // wait for Connects init to finish
52
- const { connect, create } = await this._getAPIPromises('init');
53
- await connect.promise;
54
- // send back the Create cache so the SDK can use it to insert & delete
55
- // documents/assets/etc
56
- create.resolve(cache);
57
- }
58
- async updateDocument(options) {
59
- const update = await this._getImplementation('documents.update');
60
- if (update) {
61
- return update(options);
62
- }
63
- throw new Error('connector.documents({ update: fn }) is not implemented');
64
- }
65
- async createDocument(options) {
66
- const create = await this._getImplementation('documents.create');
67
- if (create) {
68
- return create(options);
69
- }
70
- throw new Error('connector.documents({ create: fn }) is not implemented');
71
- }
72
- async deleteDocument(options) {
73
- const del = await this._getImplementation('documents.delete');
74
- if (del) {
75
- return del(options);
76
- }
77
- throw new Error('connector.documents({ delete: fn }) is not implemented');
78
- }
79
- async publishDocuments(options) {
80
- const publish = await this._getImplementation('documents.publish');
81
- if (publish) {
82
- return publish(options);
83
- }
84
- throw new Error('connector.documents({ publish: fn }) is not implemented');
85
- }
86
- async getSchema() {
87
- const models = await this.getModels();
88
- const locales = await this.getLocales();
89
- return {
90
- models: models || [],
91
- locales: locales || [],
92
- context: {}
93
- };
94
- }
95
- async getModels() {
96
- const { connect, create } = await this._getAPIPromises('model');
97
- const modelBuilder = await connect.promise;
98
- try {
99
- const models = modelBuilder.toCreateModels();
100
- return models;
101
- }
102
- catch (e) {
103
- create.reject(e);
104
- }
105
- finally {
106
- create.resolve();
107
- }
108
- }
109
- async getLocales() {
110
- return this.connector._getLocales();
111
- }
112
- async connectSyncFinished() {
113
- const { connect } = await this._getAPIPromises(`sync`);
114
- await connect.promise;
115
- return this.connector;
116
- }
117
- async getDocuments() {
118
- return (await this.connectSyncFinished()).restoreAllDocuments();
119
- }
120
- async getAssets() {
121
- return (await this.connectSyncFinished()).restoreAllAssets();
122
- }
123
- async uploadAsset(options) {
124
- //TODO
125
- return {
126
- id: '',
127
- type: 'asset',
128
- manageUrl: '',
129
- status: 'added',
130
- createdAt: '',
131
- updatedAt: '',
132
- fields: {},
133
- context: undefined
134
- };
135
- }
136
- async updateAsset(options) {
137
- throw new Error('connector.asset({ update: fn }) is not implemented');
138
- }
139
- getContentEngineConfig() {
140
- return {
141
- connector: 'unified-connector-test-connector',
142
- plugins: [
143
- {
144
- resolve: 'unified-connector-test-connector',
145
- options: this.options || {}
146
- }
147
- ]
148
- };
149
- }
150
- async onFilesChange({ updatedFiles }) {
151
- return {};
152
- }
153
- }
154
- //# sourceMappingURL=connector-wrapper.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"connector-wrapper.mjs","sourceRoot":"","sources":["../../src/connector/connector-wrapper.mts"],"names":[],"mappings":"AAaA,MAAM,CAAC,OAAO,OAAO,gBAAgB;IAKjC,YAAY,EAAE,WAAW,EAAE,MAAM,EAAoD;QACjF,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,SAAS,GAAG,WAAW,CAAC,oBAAoB,CAAC;IACtD,CAAC;IAED,oBAAoB;QAChB,OAAO;QACP,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,YAAY;QACR,OAAO;QACP,OAAO,GAAG,CAAC;IACf,CAAC;IAED,KAAK,CAAC,UAAU;QACZ,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAAC;IACtE,CAAC;IAED,qBAAqB;QACjB,OAAO;QACP,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,mBAAmB;QACf,OAAO,IAAI,CAAC,SAAS,CAAC,oBAAoB,EAAE,CAAC;IACjD,CAAC;IAED,gEAAgE;IAChE,0BAA0B;IAC1B,SAAS;QACL,OAAO,OAAO,CAAC,OAAO,CAAC;YACnB,cAAc,EAAE,IAAI;YACpB,aAAa,EAAE,IAAI;SACtB,CAAC,CAAC;IACP,CAAC;IAED,iBAAiB;QACb,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC;IAC3C,CAAC;IAED,uCAAuC;IACvC,KAAK;QACD,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC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AM,EAAE,OAAO,EAAE,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;QACvD,MAAM,OAAO,CAAC,OAAO,CAAC;QACtB,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,YAAY;QACd,OAAO,CAAC,MAAM,IAAI,CAAC,mBAAmB,EAAE,CAAC,CAAC,mBAAmB,EAAE,CAAC;IACpE,CAAC;IAED,KAAK,CAAC,SAAS;QACX,OAAO,CAAC,MAAM,IAAI,CAAC,mBAAmB,EAAE,CAAC,CAAC,gBAAgB,EAAE,CAAC;IACjE,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,OAOjB;QACG,MAAM;QACN,OAAO;YACH,EAAE,EAAE,EAAE;YACN,IAAI,EAAE,OAAO;YACb,SAAS,EAAE,EAAE;YACb,MAAM,EAAE,OAAO;YACf,SAAS,EAAE,EAAE;YACb,SAAS,EAAE,EAAE;YACb,MAAM,EAAE,EAAE;YACV,OAAO,EAAE,SAAS;SACH,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,OAIjB;QACG,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;IAC1E,CAAC;IAED,sBAAsB;QAClB,OAAO;YACH,SAAS,EAAE,kCAAkC;YAC7C,OAAO,EAAE;gBACL;oBACI,OAAO,EAAE,kCAAkC;oBAC3C,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,EAAE;iBAC9B;aACJ;SACJ,CAAC;IACN,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,EAChB,YAAY,EAGf;QACG,OAAO,EAAE,CAAC;IACd,CAAC;CACJ"}
@@ -1,226 +0,0 @@
1
- import { NetlifyIntegration } from '@netlify/sdk';
2
- import {
3
- Asset,
4
- ContentChanges,
5
- ContentEngineConfig,
6
- ContentSourceInterface,
7
- Document,
8
- Model,
9
- UpdateOperation,
10
- UpdateOperationField,
11
- UserSSOProfile
12
- } from '@stackbit/types';
13
-
14
- export default class ConnectorWrapper implements ContentSourceInterface {
15
- private integration: NetlifyIntegration;
16
- private options: any;
17
- private connector: any;
18
-
19
- constructor({ integration, config }: { integration: NetlifyIntegration; config: any }) {
20
- this.integration = integration;
21
- this.options = config;
22
- this.connector = integration.netlifyConnectPlugin;
23
- }
24
-
25
- getContentSourceType() {
26
- // todo
27
- return 'todo';
28
- }
29
-
30
- getProjectId() {
31
- // todo
32
- return '1';
33
- }
34
-
35
- async getVersion() {
36
- return { interfaceVersion: '0.7.3', contentSourceVersion: '0.1' };
37
- }
38
-
39
- getProjectEnvironment() {
40
- // todo
41
- return 'main';
42
- }
43
-
44
- getProjectManageUrl() {
45
- return this.connector._getProjectManageUrl();
46
- }
47
-
48
- // todo make these custom error classes to be thrown from within
49
- // sync/create/publish/etc
50
- hasAccess() {
51
- return Promise.resolve({
52
- hasPermissions: true,
53
- hasConnection: true
54
- });
55
- }
56
-
57
- validateDocuments() {
58
- return Promise.resolve({ errors: [] });
59
- }
60
-
61
- // for now reset/destroy are not needed
62
- reset() {
63
- return Promise.resolve();
64
- }
65
-
66
- destroy() {
67
- return Promise.resolve();
68
- }
69
-
70
- async _getAPIPromises(name: string) {
71
- return this.connector.getAPIPromises(name);
72
- }
73
-
74
- async _getImplementation(name: string) {
75
- return this.connector.definedImplementations.get(name);
76
- }
77
-
78
- async init({ cache }: { cache: any }) {
79
- this.integration.netlifyConnectPlugin?.setRuntimeSupportsCreate();
80
- // wait for Connects init to finish
81
- const { connect, create } = await this._getAPIPromises('init');
82
- await connect.promise;
83
- // send back the Create cache so the SDK can use it to insert & delete
84
- // documents/assets/etc
85
- create.resolve(cache);
86
- }
87
-
88
- async updateDocument(options: {
89
- document: Document<unknown>;
90
- operations: UpdateOperation[];
91
- userContext?: { name: string; email: string; sso?: UserSSOProfile | undefined } | undefined;
92
- }): Promise<void> {
93
- const update = await this._getImplementation('documents.update');
94
- if (update) {
95
- return update(options);
96
- }
97
- throw new Error('connector.documents({ update: fn }) is not implemented');
98
- }
99
-
100
- async createDocument(options: {
101
- updateOperationFields: Record<string, UpdateOperationField>;
102
- model: Model<unknown>;
103
- locale?: string | undefined;
104
- defaultLocaleDocumentId?: string | undefined;
105
- userContext?: { name: string; email: string; sso?: UserSSOProfile | undefined } | undefined;
106
- }): Promise<{ documentId: string }> {
107
- const create = await this._getImplementation('documents.create');
108
- if (create) {
109
- return create(options);
110
- }
111
- throw new Error('connector.documents({ create: fn }) is not implemented');
112
- }
113
-
114
- async deleteDocument(options: {
115
- document: Document<unknown>;
116
- userContext?: { name: string; email: string; sso?: UserSSOProfile | undefined } | undefined;
117
- }): Promise<void> {
118
- const del = await this._getImplementation('documents.delete');
119
- if (del) {
120
- return del(options);
121
- }
122
- throw new Error('connector.documents({ delete: fn }) is not implemented');
123
- }
124
-
125
- async publishDocuments(options: {
126
- documents: Document<unknown>[];
127
- assets: Asset<unknown>[];
128
- userContext?: { name: string; email: string; sso?: UserSSOProfile | undefined } | undefined;
129
- }): Promise<void> {
130
- const publish = await this._getImplementation('documents.publish');
131
- if (publish) {
132
- return publish(options);
133
- }
134
- throw new Error('connector.documents({ publish: fn }) is not implemented');
135
- }
136
-
137
- async getSchema() {
138
- const models = await this.getModels();
139
- const locales = await this.getLocales();
140
- return {
141
- models: models || [],
142
- locales: locales || [],
143
- context: {}
144
- };
145
- }
146
-
147
- async getModels() {
148
- const { connect, create } = await this._getAPIPromises('model');
149
- const modelBuilder = await connect.promise;
150
- try {
151
- const models = modelBuilder.toCreateModels();
152
- return models;
153
- } catch (e) {
154
- create.reject(e);
155
- } finally {
156
- create.resolve();
157
- }
158
- }
159
-
160
- async getLocales() {
161
- return this.connector._getLocales();
162
- }
163
-
164
- async connectSyncFinished() {
165
- const { connect } = await this._getAPIPromises(`sync`);
166
- await connect.promise;
167
- return this.connector;
168
- }
169
-
170
- async getDocuments(): Promise<Document<unknown>[]> {
171
- return (await this.connectSyncFinished()).restoreAllDocuments();
172
- }
173
-
174
- async getAssets(): Promise<Asset<unknown>[]> {
175
- return (await this.connectSyncFinished()).restoreAllAssets();
176
- }
177
-
178
- async uploadAsset(options: {
179
- url?: string | undefined;
180
- base64?: string | undefined;
181
- fileName: string;
182
- mimeType: string;
183
- locale?: string | undefined;
184
- userContext?: { name: string; email: string; sso?: UserSSOProfile | undefined } | undefined;
185
- }): Promise<Asset<unknown>> {
186
- //TODO
187
- return {
188
- id: '',
189
- type: 'asset',
190
- manageUrl: '',
191
- status: 'added',
192
- createdAt: '',
193
- updatedAt: '',
194
- fields: {},
195
- context: undefined
196
- } as Asset<unknown>;
197
- }
198
-
199
- async updateAsset(options: {
200
- asset: Asset<unknown>;
201
- operations: UpdateOperation[];
202
- userContext?: { name: string; email: string; sso?: UserSSOProfile | undefined } | undefined;
203
- }): Promise<void> {
204
- throw new Error('connector.asset({ update: fn }) is not implemented');
205
- }
206
-
207
- getContentEngineConfig(): ContentEngineConfig {
208
- return {
209
- connector: 'unified-connector-test-connector', //TODO
210
- plugins: [
211
- {
212
- resolve: 'unified-connector-test-connector', //TODO
213
- options: this.options || {}
214
- }
215
- ]
216
- };
217
- }
218
-
219
- async onFilesChange({
220
- updatedFiles
221
- }: {
222
- updatedFiles: string[];
223
- }): Promise<{ invalidateSchema?: boolean | undefined; contentChanges?: ContentChanges<unknown, unknown> | undefined }> {
224
- return {};
225
- }
226
- }