@tandem-language-exchange/content-store 1.0.3 → 1.0.4
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/client/cli.d.ts +1 -0
- package/dist/client/cli.js +72 -0
- package/dist/client/cli.js.map +1 -0
- package/dist/client/config.d.ts +6 -0
- package/dist/client/config.js +8 -0
- package/dist/client/config.js.map +1 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/sdk/client.d.ts +2 -2
- package/dist/sdk/client.js +2 -2
- package/dist/sdk/client.js.map +1 -1
- package/dist/sdk/index.d.ts +5 -5
- package/dist/sdk/index.js +3 -3
- package/dist/sdk/index.js.map +1 -1
- package/dist/shared/bundles.d.ts +2 -2
- package/dist/shared/config.d.ts +1 -1
- package/dist/shared/s3.d.ts +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { config } from './config';
|
|
3
|
+
import { ContentStore } from '../shared/s3';
|
|
4
|
+
import { fetchBundles, queryBundle } from '../shared/bundles';
|
|
5
|
+
const program = new Command();
|
|
6
|
+
program
|
|
7
|
+
.name('content-store')
|
|
8
|
+
.description('Sync CMS content to S3')
|
|
9
|
+
.version('1.0.0');
|
|
10
|
+
program
|
|
11
|
+
.command('fetch')
|
|
12
|
+
.description('Download latest bundles from S3 to the local filesystem')
|
|
13
|
+
.requiredOption('--cms <provider>', 'CMS provider: contentful | sanity')
|
|
14
|
+
.requiredOption('--types <types>', 'Comma-separated content types to fetch')
|
|
15
|
+
.option('--output <directory>', 'Output directory', './content-cache')
|
|
16
|
+
.action(async (opts) => {
|
|
17
|
+
const cms = opts.cms;
|
|
18
|
+
if (!['contentful', 'sanity'].includes(cms)) {
|
|
19
|
+
console.error(`Invalid CMS provider: ${cms}`);
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
const contentTypes = opts.types.split(',').map((s) => s.trim());
|
|
23
|
+
const store = new ContentStore(config.s3);
|
|
24
|
+
try {
|
|
25
|
+
const files = await fetchBundles(store, opts.output, {
|
|
26
|
+
cms,
|
|
27
|
+
contentTypes,
|
|
28
|
+
});
|
|
29
|
+
console.log('Fetched bundles:');
|
|
30
|
+
for (const [type, filePath] of Object.entries(files)) {
|
|
31
|
+
console.log(` ${type} -> ${filePath}`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
console.error('Fetch failed:', err);
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
program
|
|
40
|
+
.command('query')
|
|
41
|
+
.description('Query a previously fetched bundle from the local filesystem')
|
|
42
|
+
.requiredOption('--cms <provider>', 'CMS provider: contentful | sanity')
|
|
43
|
+
.requiredOption('--type <type>', 'Content type to query')
|
|
44
|
+
.option('--output <directory>', 'Directory where bundles are stored', './content-cache')
|
|
45
|
+
.option('--fields <json>', 'Filter by fields (JSON object, e.g. \'{"columns":"2"}\')')
|
|
46
|
+
.option('--select <props>', 'Comma-separated properties to include in results')
|
|
47
|
+
.option('--limit <n>', 'Maximum number of results', parseInt)
|
|
48
|
+
.option('--include <n>', 'Depth of nested references to include', parseInt)
|
|
49
|
+
.action(async (opts) => {
|
|
50
|
+
const cms = opts.cms;
|
|
51
|
+
if (!['contentful', 'sanity'].includes(cms)) {
|
|
52
|
+
console.error(`Invalid CMS provider: ${cms}`);
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
const results = await queryBundle(opts.output, cms, opts.type, {
|
|
57
|
+
fields: opts.fields ? JSON.parse(opts.fields) : undefined,
|
|
58
|
+
select: opts.select
|
|
59
|
+
? opts.select.split(',').map((s) => s.trim())
|
|
60
|
+
: undefined,
|
|
61
|
+
limit: opts.limit,
|
|
62
|
+
include: opts.include,
|
|
63
|
+
});
|
|
64
|
+
console.log(JSON.stringify(results, null, 2));
|
|
65
|
+
}
|
|
66
|
+
catch (err) {
|
|
67
|
+
console.error('Query failed:', err);
|
|
68
|
+
process.exit(1);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
program.parse();
|
|
72
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/client/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,EAAoB,MAAM,UAAU,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAE9D,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,eAAe,CAAC;KACrB,WAAW,CAAC,wBAAwB,CAAC;KACrC,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,OAAO;KACF,OAAO,CAAC,OAAO,CAAC;KAChB,WAAW,CAAC,yDAAyD,CAAC;KACtE,cAAc,CAAC,kBAAkB,EAAE,mCAAmC,CAAC;KACvE,cAAc,CAAC,iBAAiB,EAAE,wCAAwC,CAAC;KAC3E,MAAM,CAAC,sBAAsB,EAAE,kBAAkB,EAAE,iBAAiB,CAAC;KACrE,MAAM,CAAC,KAAK,EAAE,IAAoD,EAAE,EAAE;IACvE,MAAM,GAAG,GAAG,IAAI,CAAC,GAAkB,CAAC;IAEpC,IAAI,CAAC,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAC5C,OAAO,CAAC,KAAK,CAAC,yBAAyB,GAAG,EAAE,CAAC,CAAC;QAC9C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,M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":"","sources":["../../src/client/config.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAe,MAAM,IAAI,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAEtE,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC;AACtC,MAAM,CAAC,MAAM,EAAE,CAAC;AAOhB,MAAM,CAAC,MAAM,MAAM,GAAgC;IAC/C,GAAG,YAAY;CAClB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { ContentStoreSDK } from './sdk/index
|
|
2
|
-
export type { SDKConfig, FetchBundlesOptions, QueryOptions } from './sdk/index
|
|
3
|
-
export { fetchBundles, queryBundle, trimDepth } from './shared/bundles
|
|
4
|
-
export { ContentStore } from './shared/s3
|
|
5
|
-
export type { CMSProvider, S3Config } from './shared/types
|
|
1
|
+
export { ContentStoreSDK } from './sdk/index';
|
|
2
|
+
export type { SDKConfig, FetchBundlesOptions, QueryOptions } from './sdk/index';
|
|
3
|
+
export { fetchBundles, queryBundle, trimDepth } from './shared/bundles';
|
|
4
|
+
export { ContentStore } from './shared/s3';
|
|
5
|
+
export type { CMSProvider, S3Config } from './shared/types';
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { ContentStoreSDK } from './sdk/index
|
|
2
|
-
export { fetchBundles, queryBundle, trimDepth } from './shared/bundles
|
|
3
|
-
export { ContentStore } from './shared/s3
|
|
1
|
+
export { ContentStoreSDK } from './sdk/index';
|
|
2
|
+
export { fetchBundles, queryBundle, trimDepth } from './shared/bundles';
|
|
3
|
+
export { ContentStore } from './shared/s3';
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/sdk/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { S3Config, CMSProvider } from '../shared/types
|
|
2
|
-
import { type FetchBundlesOptions, type QueryOptions } from '../shared/bundles
|
|
1
|
+
import type { S3Config, CMSProvider } from '../shared/types';
|
|
2
|
+
import { type FetchBundlesOptions, type QueryOptions } from '../shared/bundles';
|
|
3
3
|
export type { FetchBundlesOptions, QueryOptions };
|
|
4
4
|
export interface SDKConfig {
|
|
5
5
|
s3: S3Config;
|
package/dist/sdk/client.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ContentStore } from '../shared/s3
|
|
2
|
-
import { fetchBundles, queryBundle, } from '../shared/bundles
|
|
1
|
+
import { ContentStore } from '../shared/s3';
|
|
2
|
+
import { fetchBundles, queryBundle, } from '../shared/bundles';
|
|
3
3
|
export class ContentStoreSDK {
|
|
4
4
|
store;
|
|
5
5
|
outputDir;
|
package/dist/sdk/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/sdk/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/sdk/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EACL,YAAY,EACZ,WAAW,GAGZ,MAAM,mBAAmB,CAAC;AAU3B,MAAM,OAAO,eAAe;IAClB,KAAK,CAAe;IACpB,SAAS,CAAS;IAE1B,YAAY,MAAiB;QAC3B,IAAI,CAAC,KAAK,GAAG,IAAI,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACzC,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;IACpC,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,YAAY,CAChB,OAA4B;QAE5B,OAAO,YAAY,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAC3D,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,WAAW,CACf,GAAgB,EAChB,WAAmB,EACnB,UAAwB,EAAE;QAE1B,OAAO,WAAW,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;IAChE,CAAC;CACF"}
|
package/dist/sdk/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { ContentStoreSDK } from './client
|
|
2
|
-
export type { SDKConfig, FetchBundlesOptions, QueryOptions } from './client
|
|
3
|
-
export { fetchBundles, queryBundle, trimDepth } from '../shared/bundles
|
|
4
|
-
export { ContentStore } from '../shared/s3
|
|
5
|
-
export type { S3Config, CMSProvider } from '../shared/types
|
|
1
|
+
export { ContentStoreSDK } from './client';
|
|
2
|
+
export type { SDKConfig, FetchBundlesOptions, QueryOptions } from './client';
|
|
3
|
+
export { fetchBundles, queryBundle, trimDepth } from '../shared/bundles';
|
|
4
|
+
export { ContentStore } from '../shared/s3';
|
|
5
|
+
export type { S3Config, CMSProvider } from '../shared/types';
|
package/dist/sdk/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { ContentStoreSDK } from './client
|
|
2
|
-
export { fetchBundles, queryBundle, trimDepth } from '../shared/bundles
|
|
3
|
-
export { ContentStore } from '../shared/s3
|
|
1
|
+
export { ContentStoreSDK } from './client';
|
|
2
|
+
export { fetchBundles, queryBundle, trimDepth } from '../shared/bundles';
|
|
3
|
+
export { ContentStore } from '../shared/s3';
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
package/dist/sdk/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sdk/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sdk/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/shared/bundles.d.ts
CHANGED
package/dist/shared/config.d.ts
CHANGED
package/dist/shared/s3.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tandem-language-exchange/content-store",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
"files": [
|
|
14
14
|
"dist/index.*",
|
|
15
15
|
"dist/sdk/",
|
|
16
|
-
"dist/
|
|
16
|
+
"dist/client/",
|
|
17
17
|
"dist/shared/"
|
|
18
18
|
],
|
|
19
19
|
"bin": {
|
|
20
|
-
"fetch-content-bundles": "dist/
|
|
20
|
+
"fetch-content-bundles": "dist/client/cli.js fetch"
|
|
21
21
|
},
|
|
22
22
|
"engines": {
|
|
23
23
|
"npm": "^11.3.0",
|