@sanity/blueprints 0.27.0 → 0.29.0

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.
Files changed (63) hide show
  1. package/README.md +38 -14
  2. package/dist/definers/functions/durable.d.ts +0 -1
  3. package/dist/definers/functions/durable.js +3 -4
  4. package/dist/definers/functions/durable.js.map +1 -1
  5. package/dist/definers/functions/queue.js +3 -3
  6. package/dist/definers/functions/queue.js.map +1 -1
  7. package/dist/definers/functions/scheduled.d.ts +1 -3
  8. package/dist/definers/functions/scheduled.js +1 -3
  9. package/dist/definers/functions/scheduled.js.map +1 -1
  10. package/dist/resolve/by-name.d.ts +7 -0
  11. package/dist/resolve/by-name.js +13 -0
  12. package/dist/resolve/by-name.js.map +1 -0
  13. package/dist/resolve/import.d.ts +16 -0
  14. package/dist/resolve/import.js +48 -0
  15. package/dist/resolve/import.js.map +1 -0
  16. package/dist/resolve/index.d.ts +18 -0
  17. package/dist/resolve/index.js +19 -0
  18. package/dist/resolve/index.js.map +1 -0
  19. package/dist/resolve/load.d.ts +53 -0
  20. package/dist/resolve/load.js +155 -0
  21. package/dist/resolve/load.js.map +1 -0
  22. package/dist/resolve/stack-config.d.ts +49 -0
  23. package/dist/resolve/stack-config.js +108 -0
  24. package/dist/resolve/stack-config.js.map +1 -0
  25. package/dist/resolve/stack.d.ts +23 -0
  26. package/dist/resolve/stack.js +91 -0
  27. package/dist/resolve/stack.js.map +1 -0
  28. package/dist/resolve/types.d.ts +165 -0
  29. package/dist/resolve/types.js +2 -0
  30. package/dist/resolve/types.js.map +1 -0
  31. package/dist/types/applications.d.ts +3 -1
  32. package/dist/types/applications.js +1 -1
  33. package/dist/types/applications.js.map +1 -1
  34. package/dist/types/functions/index.d.ts +58 -10
  35. package/dist/types/installation-config.d.ts +2 -0
  36. package/dist/types/studios.d.ts +9 -1
  37. package/dist/types/studios.js.map +1 -1
  38. package/dist/utils/debounce.d.ts +20 -0
  39. package/dist/utils/debounce.js +46 -0
  40. package/dist/utils/debounce.js.map +1 -0
  41. package/dist/validation/functions.d.ts +9 -0
  42. package/dist/validation/functions.js +66 -9
  43. package/dist/validation/functions.js.map +1 -1
  44. package/dist/validation/resources.js +14 -4
  45. package/dist/validation/resources.js.map +1 -1
  46. package/package.json +22 -7
  47. package/src/definers/functions/durable.ts +3 -4
  48. package/src/definers/functions/queue.ts +3 -3
  49. package/src/definers/functions/scheduled.ts +1 -3
  50. package/src/resolve/by-name.ts +11 -0
  51. package/src/resolve/import.ts +52 -0
  52. package/src/resolve/index.ts +33 -0
  53. package/src/resolve/load.ts +166 -0
  54. package/src/resolve/stack-config.ts +116 -0
  55. package/src/resolve/stack.ts +100 -0
  56. package/src/resolve/types.ts +179 -0
  57. package/src/types/applications.ts +4 -1
  58. package/src/types/functions/index.ts +70 -19
  59. package/src/types/installation-config.ts +3 -0
  60. package/src/types/studios.ts +11 -1
  61. package/src/utils/debounce.ts +53 -0
  62. package/src/validation/functions.ts +78 -12
  63. package/src/validation/resources.ts +13 -4
package/README.md CHANGED
@@ -53,11 +53,13 @@ export default defineBlueprint({
53
53
 
54
54
  defineRobotToken({
55
55
  name: 'ci-robot',
56
- memberships: [{
57
- resourceType: 'project',
58
- resourceId: 'your-project-id',
59
- roleNames: ['developer'],
60
- }],
56
+ memberships: [
57
+ {
58
+ resourceType: 'project',
59
+ resourceId: 'your-project-id',
60
+ roleNames: ['developer'],
61
+ },
62
+ ],
61
63
  }),
62
64
  ],
63
65
  })
@@ -65,14 +67,36 @@ export default defineBlueprint({
65
67
 
66
68
  ## Available resources
67
69
 
68
- | Definer | Description |
69
- |---|---|
70
- | `defineBlueprint` | Top-level blueprint module containing resources |
71
- | `defineDocumentFunction` | Function triggered by document events |
72
- | `defineMediaLibraryAssetFunction` | Function triggered by media library events |
73
- | `defineCorsOrigin` β | CORS origin allowing browser requests to your project |
74
- | `defineDocumentWebhook` β | Webhook triggered by document changes |
75
- | `defineRole` β | Custom role with permissions |
76
- | `defineRobotToken` β | Robot token for automated access |
70
+ | Definer | Description |
71
+ | --------------------------------- | ----------------------------------------------------- |
72
+ | `defineBlueprint` | Top-level blueprint module containing resources |
73
+ | `defineDocumentFunction` | Function triggered by document events |
74
+ | `defineMediaLibraryAssetFunction` | Function triggered by media library events |
75
+ | `defineCorsOrigin` β | CORS origin allowing browser requests to your project |
76
+ | `defineDocumentWebhook` β | Webhook triggered by document changes |
77
+ | `defineRole` β | Custom role with permissions |
78
+ | `defineRobotToken` β | Robot token for automated access |
77
79
 
78
80
  Each definer validates its input at call time and returns a typed resource object. See the [reference docs](https://reference.sanity.io/_sanity/blueprints) for full configuration details and additional resource types.
81
+
82
+ ## Reading a blueprint and its Stack
83
+
84
+ The Sanity CLI handles this for you. For scripts and tools, `@sanity/blueprints/resolve` reads a local blueprint and its deployed Stack.
85
+
86
+ ```ts
87
+ import {readBlueprint, readStack} from '@sanity/blueprints/resolve'
88
+
89
+ const blueprint = await readBlueprint()
90
+
91
+ blueprint.path // '/path/to/project/sanity.blueprint.ts'
92
+ blueprint.resourcesByName['production-dataset']?.type // 'sanity.project.dataset'
93
+ blueprint.stackId // 'ST-abc123'
94
+
95
+ const {stack, resourcesByName, values} = await readStack({token: process.env.SANITY_AUTH_TOKEN})
96
+
97
+ stack.name // the Stack's name
98
+ resourcesByName['my-function']?.externalId // a function's external ID
99
+ values['production-dataset']?.name // the deployed dataset's name
100
+ ```
101
+
102
+ See the [reference docs](https://reference.sanity.io/_sanity/blueprints) for options.
@@ -10,7 +10,6 @@ import { type BlueprintDurableConfig, type BlueprintDurableFunctionResource } fr
10
10
  * event: {type: 'document', on: ['create'], filter: "_type == 'post'"},
11
11
  * concurrency: 5,
12
12
  * debounce: 10,
13
- * debounceKey: 'document._id',
14
13
  * })
15
14
  * ```
16
15
  *
@@ -1,4 +1,5 @@
1
1
  import { validateDurableFunction } from '../../index.js';
2
+ import { createDebounceObject } from '../../utils/debounce.js';
2
3
  import { parseDuration } from '../../utils/parse-duration.js';
3
4
  import { runValidation } from '../../utils/validation.js';
4
5
  import { defineFunction } from './index.js';
@@ -13,7 +14,6 @@ import { defineFunction } from './index.js';
13
14
  * event: {type: 'document', on: ['create'], filter: "_type == 'post'"},
14
15
  * concurrency: 5,
15
16
  * debounce: 10,
16
- * debounceKey: 'document._id',
17
17
  * })
18
18
  * ```
19
19
  *
@@ -27,15 +27,14 @@ import { defineFunction } from './index.js';
27
27
  * @returns The validated durable function resource
28
28
  */
29
29
  export function defineDurableFunction(functionConfig) {
30
- const { name, event, concurrency, debounce, debounceKey, src, durableTimeout } = functionConfig;
30
+ const { name, event, concurrency, debounce, src, durableTimeout } = functionConfig;
31
31
  const functionResource = {
32
32
  ...defineFunction({ ...functionConfig, src: src ?? `functions/${name}` }, { skipValidation: true }),
33
33
  type: 'sanity.function.durable',
34
34
  ...(event !== undefined && { event }),
35
35
  ...(durableTimeout !== undefined && { durableTimeout: parseDuration(durableTimeout, 's') }),
36
36
  ...(concurrency !== undefined && { concurrency }),
37
- ...(debounce !== undefined && { debounce }),
38
- ...(debounceKey !== undefined && { debounceKey }),
37
+ ...(debounce !== undefined && { debounce: createDebounceObject(debounce) }),
39
38
  };
40
39
  runValidation(() => validateDurableFunction(functionResource));
41
40
  return functionResource;
@@ -1 +1 @@
1
- {"version":3,"file":"durable.js","sourceRoot":"","sources":["../../../src/definers/functions/durable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqE,uBAAuB,EAAC,MAAM,gBAAgB,CAAA;AAC1H,OAAO,EAAC,aAAa,EAAC,MAAM,+BAA+B,CAAA;AAC3D,OAAO,EAAC,aAAa,EAAC,MAAM,2BAA2B,CAAA;AACvD,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAA;AAEzC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,qBAAqB,CAAC,cAAsC;IAC1E,MAAM,EAAC,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,EAAE,cAA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,GAAG,cAAc,CAAA;IAChF,MAAM,gBAAgB,GAAqC;QACzD,GAAG,cAAc,CAAC,EAAC,GAAG,cAAc,EAAE,GAAG,EAAE,GAAG,IAAI,aAAa,IAAI,EAAE,EAAC,EAAE,EAAC,cAAc,EAAE,IAAI,EAAC,CAAC;QAC/F,IAAI,EAAE,yBAAyB;QAC/B,GAAG,CAAC,KAAK,KAAK,SAAS,IAAI,EAAC,KAAK,EAAC,CAAC;QACnC,GAAG,CAAC,cAAc,KAAK,SAAS,IAAI,EAAC,cAAc,EAAE,aAAa,CAAC,cAAc,EAAE,GAAG,CAAC,EAAC,CAAC;QACzF,GAAG,CAAC,WAAW,KAAK,SAAS,IAAI,EAAC,WAAW,EAAC,CAAC;QAC/C,GAAG,CAAC,QAAQ,KAAK,SAAS,IAAI,EAAC,QAAQ,EAAE,oBAAoB,CAAC,QAAQ,CAAC,EAAC,CAAC;KAC1E,CAAA;IAED,aAAa,CAAC,GAAG,EAAE,CAAC,uBAAuB,CAAC,gBAAgB,CAAC,CAAC,CAAA;IAC9D,OAAO,gBAAgB,CAAA;AACzB,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { validateQueueFunction } from '../../index.js';
2
+ import { createDebounceObject } from '../../utils/debounce.js';
2
3
  import { runValidation } from '../../utils/validation.js';
3
4
  import { defineFunction } from './index.js';
4
5
  /**
@@ -30,13 +31,12 @@ import { defineFunction } from './index.js';
30
31
  * @returns The validated queue function resource
31
32
  */
32
33
  export function defineQueueFunction(functionConfig) {
33
- const { concurrency = 1, fifo = true, dlq = true, debounce, debounceKey, event } = functionConfig;
34
+ const { concurrency = 1, fifo = true, dlq = true, debounce, event } = functionConfig;
34
35
  const functionResource = {
35
36
  ...defineFunction(functionConfig, { skipValidation: true }),
36
37
  type: 'sanity.function.queue',
37
38
  ...(concurrency !== undefined && { concurrency }),
38
- ...(debounce !== undefined && { debounce }),
39
- ...(debounceKey !== undefined && { debounceKey }),
39
+ ...(debounce !== undefined && { debounce: createDebounceObject(debounce) }),
40
40
  ...(dlq !== undefined && { dlq }),
41
41
  ...(event !== undefined && { event }),
42
42
  ...(fifo !== undefined && { fifo }),
@@ -1 +1 @@
1
- {"version":3,"file":"queue.js","sourceRoot":"","sources":["../../../src/definers/functions/queue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyE,qBAAqB,EAAC,MAAM,gBAAgB,CAAA;AAC5H,OAAO,EAAC,aAAa,EAAC,MAAM,2BAA2B,CAAA;AACvD,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAA;AACzC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,UAAU,mBAAmB,CAAC,cAA4C;IAC9E,MAAM,EAAC,WAAW,GAAG,CAAC,EAAE,IAAI,GAAG,IAAI,EAAE,GAAG,GAAG,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,KAAK,EAAC,GAAG,cAAc,CAAA;IAE/F,MAAM,gBAAgB,GAAmC;QACvD,GAAG,cAAc,CAAC,cAAc,EAAE,EAAC,cAAc,EAAE,IAAI,EAAC,CAAC;QACzD,IAAI,EAAE,uBAAuB;QAC7B,GAAG,CAAC,WAAW,KAAK,SAAS,IAAI,EAAC,WAAW,EAAC,CAAC;QAC/C,GAAG,CAAC,QAAQ,KAAK,SAAS,IAAI,EAAC,QAAQ,EAAC,CAAC;QACzC,GAAG,CAAC,WAAW,KAAK,SAAS,IAAI,EAAC,WAAW,EAAC,CAAC;QAC/C,GAAG,CAAC,GAAG,KAAK,SAAS,IAAI,EAAC,GAAG,EAAC,CAAC;QAC/B,GAAG,CAAC,KAAK,KAAK,SAAS,IAAI,EAAC,KAAK,EAAC,CAAC;QACnC,GAAG,CAAC,IAAI,KAAK,SAAS,IAAI,EAAC,IAAI,EAAC,CAAC;KAClC,CAAA;IAED,aAAa,CAAC,GAAG,EAAE,CAAC,qBAAqB,CAAC,gBAAgB,CAAC,CAAC,CAAA;IAE5D,OAAO,gBAAgB,CAAA;AACzB,CAAC"}
1
+ {"version":3,"file":"queue.js","sourceRoot":"","sources":["../../../src/definers/functions/queue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyE,qBAAqB,EAAC,MAAM,gBAAgB,CAAA;AAC5H,OAAO,EAAC,oBAAoB,EAAC,MAAM,yBAAyB,CAAA;AAC5D,OAAO,EAAC,aAAa,EAAC,MAAM,2BAA2B,CAAA;AACvD,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAA;AACzC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,UAAU,mBAAmB,CAAC,cAA4C;IAC9E,MAAM,EAAC,WAAW,GAAG,CAAC,EAAE,IAAI,GAAG,IAAI,EAAE,GAAG,GAAG,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAC,GAAG,cAAc,CAAA;IAElF,MAAM,gBAAgB,GAAmC;QACvD,GAAG,cAAc,CAAC,cAAc,EAAE,EAAC,cAAc,EAAE,IAAI,EAAC,CAAC;QACzD,IAAI,EAAE,uBAAuB;QAC7B,GAAG,CAAC,WAAW,KAAK,SAAS,IAAI,EAAC,WAAW,EAAC,CAAC;QAC/C,GAAG,CAAC,QAAQ,KAAK,SAAS,IAAI,EAAC,QAAQ,EAAE,oBAAoB,CAAC,QAAQ,CAAC,EAAC,CAAC;QACzE,GAAG,CAAC,GAAG,KAAK,SAAS,IAAI,EAAC,GAAG,EAAC,CAAC;QAC/B,GAAG,CAAC,KAAK,KAAK,SAAS,IAAI,EAAC,KAAK,EAAC,CAAC;QACnC,GAAG,CAAC,IAAI,KAAK,SAAS,IAAI,EAAC,IAAI,EAAC,CAAC;KAClC,CAAA;IAED,aAAa,CAAC,GAAG,EAAE,CAAC,qBAAqB,CAAC,gBAAgB,CAAC,CAAC,CAAA;IAE5D,OAAO,gBAAgB,CAAA;AACzB,CAAC"}
@@ -30,12 +30,10 @@ import { type BlueprintScheduledFunctionConfig, type BlueprintScheduledFunctionR
30
30
  * event: {expression: 'every day at 9am'},
31
31
  * })
32
32
  * ```
33
+ * @param functionConfig The configuration for the scheduled function
33
34
  * @public
34
- * @alpha Deploying Scheduled Functions via Blueprints is experimental. This feature is not available publicly yet.
35
- * @hidden
36
35
  * @category Definers
37
36
  * @expandType BlueprintScheduledFunctionConfig
38
- * @param functionConfig The configuration for the scheduled function
39
37
  * @returns The validated scheduled function resource
40
38
  */
41
39
  export declare function defineScheduledFunction(functionConfig: BlueprintScheduledFunctionConfig): BlueprintScheduledFunctionResource;
@@ -34,12 +34,10 @@ const SCHEDULED_EVENT_KEYS = new Set(['minute', 'hour', 'dayOfWeek', 'month', 'd
34
34
  * event: {expression: 'every day at 9am'},
35
35
  * })
36
36
  * ```
37
+ * @param functionConfig The configuration for the scheduled function
37
38
  * @public
38
- * @alpha Deploying Scheduled Functions via Blueprints is experimental. This feature is not available publicly yet.
39
- * @hidden
40
39
  * @category Definers
41
40
  * @expandType BlueprintScheduledFunctionConfig
42
- * @param functionConfig The configuration for the scheduled function
43
41
  * @returns The validated scheduled function resource
44
42
  */
45
43
  export function defineScheduledFunction(functionConfig) {
@@ -1 +1 @@
1
- {"version":3,"file":"scheduled.js","sourceRoot":"","sources":["../../../src/definers/functions/scheduled.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,yBAAyB,GAC1B,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAC,wBAAwB,EAAC,MAAM,gCAAgC,CAAA;AACvE,OAAO,EAAC,aAAa,EAAC,MAAM,2BAA2B,CAAA;AACvD,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAA;AAKzC,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAA4B,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC,CAAA;AAErI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,MAAM,UAAU,uBAAuB,CAAC,cAAgD;IACtF,MAAM,EAAC,KAAK,EAAE,QAAQ,EAAC,GAAG,cAAc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C,UAAU,KAAK,QAAQ,EAAE,CAAC;QACpG,MAAM,IAAI,GAAG,wBAAwB,CAAC,gBAAgB,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA;QACxE,gBAAgB,CAAC,KAAK,GAAG,yBAAyB,CAAC,IAAI,CAAC,CAAA;IAC1D,CAAC;IAED,aAAa,CAAC,GAAG,EAAE,CAAC,yBAAyB,CAAC,gBAAgB,CAAC,CAAC,CAAA;IAEhE,OAAO,gBAAgB,CAAA;AACzB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,cAAgD;IACrF,OAAO,uBAAuB,CAAC,cAAc,CAAC,CAAA;AAChD,CAAC;AAED;;;;;GAKG;AACH,SAAS,2BAA2B,CAAC,KAA4C;IAC/E,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,oBAAoB,CAAC,GAAG,CAAC,GAAgC,CAAC,CAAC,CACzD,CAAA;AAC9C,CAAC;AAED;;;;GAIG;AACH,SAAS,yBAAyB,CAAC,IAAY;IAC7C,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IACtC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,+CAA+C,KAAK,CAAC,MAAM,EAAE,CAAC,CAAA;IAChF,CAAC;IACD,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,CAAC,GAAG,KAAK,CAAA;IAC1D,OAAO,EAAC,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,EAAC,CAAA;AACrD,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Key resources by name. A resource without a string `name` is left out, and a later resource with the same name replaces an earlier one.
3
+ * @internal
4
+ */
5
+ export declare function byName<T extends {
6
+ name?: unknown;
7
+ }>(resources: T[]): Record<string, T>;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Key resources by name. A resource without a string `name` is left out, and a later resource with the same name replaces an earlier one.
3
+ * @internal
4
+ */
5
+ export function byName(resources) {
6
+ const keyed = {};
7
+ for (const resource of resources) {
8
+ if (typeof resource?.name === 'string')
9
+ keyed[resource.name] = resource;
10
+ }
11
+ return keyed;
12
+ }
13
+ //# sourceMappingURL=by-name.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"by-name.js","sourceRoot":"","sources":["../../src/resolve/by-name.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,MAAM,CAA6B,SAAc;IAC/D,MAAM,KAAK,GAAsB,EAAE,CAAA;IACnC,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,IAAI,OAAO,QAAQ,EAAE,IAAI,KAAK,QAAQ;YAAE,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAA;IACzE,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { BlueprintLoader } from './types.js';
2
+ /**
3
+ * Import a file natively and return its default export
4
+ * @internal
5
+ */
6
+ export declare function importNative(path: string): Promise<unknown>;
7
+ /**
8
+ * Whether jiti may be able to import a file that the native import could not
9
+ * @internal
10
+ */
11
+ export declare function canRetryWithJiti(error: unknown): boolean;
12
+ /**
13
+ * A jiti loader, when jiti resolves from the blueprint file or from this package
14
+ * @internal
15
+ */
16
+ export declare function findJiti(path: string): Promise<BlueprintLoader | undefined>;
@@ -0,0 +1,48 @@
1
+ import { createRequire } from 'node:module';
2
+ import { pathToFileURL } from 'node:url';
3
+ /*
4
+ * Error strings thrown by Node when importing a .ts file.
5
+ * Indicators to attempt again with jiti.
6
+ */
7
+ const RETRY_WITH_JITI = new Set([
8
+ 'ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX',
9
+ 'ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING',
10
+ 'ERR_UNKNOWN_FILE_EXTENSION',
11
+ 'ERR_MODULE_NOT_FOUND',
12
+ ]);
13
+ /**
14
+ * Import a file natively and return its default export
15
+ * @internal
16
+ */
17
+ export async function importNative(path) {
18
+ const imported = await import(pathToFileURL(path).href);
19
+ return imported.default;
20
+ }
21
+ /**
22
+ * Whether jiti may be able to import a file that the native import could not
23
+ * @internal
24
+ */
25
+ export function canRetryWithJiti(error) {
26
+ return error instanceof Error && 'code' in error && RETRY_WITH_JITI.has(String(error.code));
27
+ }
28
+ /**
29
+ * A jiti loader, when jiti resolves from the blueprint file or from this package
30
+ * @internal
31
+ */
32
+ export async function findJiti(path) {
33
+ for (const from of [path, import.meta.url]) {
34
+ let resolved;
35
+ try {
36
+ resolved = createRequire(from).resolve('jiti');
37
+ }
38
+ catch {
39
+ continue;
40
+ }
41
+ const { createJiti } = await import(pathToFileURL(resolved).href);
42
+ if (typeof createJiti !== 'function')
43
+ continue;
44
+ return (file) => createJiti(file).import(pathToFileURL(file).href, { default: true });
45
+ }
46
+ return undefined;
47
+ }
48
+ //# sourceMappingURL=import.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import.js","sourceRoot":"","sources":["../../src/resolve/import.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,aAAa,CAAA;AACzC,OAAO,EAAC,aAAa,EAAC,MAAM,UAAU,CAAA;AAKtC;;;GAGG;AACH,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC;IAC9B,mCAAmC;IACnC,6CAA6C;IAC7C,4BAA4B;IAC5B,sBAAsB;CACvB,CAAC,CAAA;AAEF;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,IAAY;IAC7C,MAAM,QAAQ,GAAwB,MAAM,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAA;IAC5E,OAAO,QAAQ,CAAC,OAAO,CAAA;AACzB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,OAAO,KAAK,YAAY,KAAK,IAAI,MAAM,IAAI,KAAK,IAAI,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;AAC7F,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,IAAY;IACzC,KAAK,MAAM,IAAI,IAAI,CAAC,IAAI,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QAC3C,IAAI,QAAgB,CAAA;QACpB,IAAI,CAAC;YACH,QAAQ,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QAChD,CAAC;QAAC,MAAM,CAAC;YACP,SAAQ;QACV,CAAC;QACD,MAAM,EAAC,UAAU,EAAC,GAA8B,MAAM,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAA;QAC1F,IAAI,OAAO,UAAU,KAAK,UAAU;YAAE,SAAQ;QAC9C,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAC,OAAO,EAAE,IAAI,EAAC,CAAC,CAAA;IACrF,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * `@sanity/blueprints/resolve`
3
+ *
4
+ * A Blueprint declares resources. A Stack is its deployed counterpart.
5
+ * {@link readBlueprint} reads local blueprint.
6
+ * {@link readStack} reads remote stack.
7
+ *
8
+ * This entry point imports Node built-ins, so it is separate from `@sanity/blueprints`.
9
+ * @module
10
+ */
11
+ /**
12
+ * @categoryDescription Resolve
13
+ * These functions read a blueprint from disk, resolve the Stack it deploys to, and read that Stack from the Blueprints API.
14
+ */
15
+ export { BLUEPRINT_FILE_NAMES, findBlueprintFile, loadBlueprintFile, readBlueprint, } from './load.js';
16
+ export { DEFAULT_BLUEPRINTS_API_VERSION, readStack, } from './stack.js';
17
+ export { readStackConfigFile, resolveStackConfig, STACK_CONFIG_DIR, STACK_CONFIG_FILE, stackIdsFromEnv, } from './stack-config.js';
18
+ export * from './types.js';
@@ -0,0 +1,19 @@
1
+ /**
2
+ * `@sanity/blueprints/resolve`
3
+ *
4
+ * A Blueprint declares resources. A Stack is its deployed counterpart.
5
+ * {@link readBlueprint} reads local blueprint.
6
+ * {@link readStack} reads remote stack.
7
+ *
8
+ * This entry point imports Node built-ins, so it is separate from `@sanity/blueprints`.
9
+ * @module
10
+ */
11
+ /**
12
+ * @categoryDescription Resolve
13
+ * These functions read a blueprint from disk, resolve the Stack it deploys to, and read that Stack from the Blueprints API.
14
+ */
15
+ export { BLUEPRINT_FILE_NAMES, findBlueprintFile, loadBlueprintFile, readBlueprint, } from './load.js';
16
+ export { DEFAULT_BLUEPRINTS_API_VERSION, readStack, } from './stack.js';
17
+ export { readStackConfigFile, resolveStackConfig, STACK_CONFIG_DIR, STACK_CONFIG_FILE, stackIdsFromEnv, } from './stack-config.js';
18
+ export * from './types.js';
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/resolve/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;;GAGG;AACH,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,GACd,MAAM,WAAW,CAAA;AAClB,OAAO,EACL,8BAA8B,EAC9B,SAAS,GACV,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,GAChB,MAAM,mBAAmB,CAAA;AAC1B,cAAc,YAAY,CAAA"}
@@ -0,0 +1,53 @@
1
+ import type { BlueprintInfo, LoadBlueprintFileOptions, LoadedBlueprintFile, ReadBlueprintOptions } from './types.js';
2
+ /**
3
+ * The file names {@link findBlueprintFile} looks for, in order
4
+ * @internal
5
+ * @private
6
+ * @category Resolve
7
+ */
8
+ export declare const BLUEPRINT_FILE_NAMES: string[];
9
+ /**
10
+ * Find a blueprint file
11
+ *
12
+ * Returns a file path as is. Searches a directory, then its parents, for {@link BLUEPRINT_FILE_NAMES}.
13
+ *
14
+ * @param path A blueprint file or directory. Defaults to the current working directory.
15
+ * @returns The absolute path of the file, or `undefined` when none is found
16
+ * @internal
17
+ * @private
18
+ * @category Resolve
19
+ */
20
+ export declare function findBlueprintFile(path?: string): string | undefined;
21
+ /**
22
+ * Load a blueprint file
23
+ *
24
+ * Parses a JSON file. Imports a JS or TS file and calls its default export.
25
+ * TypeScript that Node cannot run, such as an enum, is loaded with jiti when it is installed.
26
+ * Imported modules are cached, so a later call in the same process does not see changes to the file. Pass a `loader` that skips the cache to re-read it.
27
+ *
28
+ * @param path The blueprint file
29
+ * @throws When the file cannot be loaded or does not produce a blueprint object
30
+ * @internal
31
+ * @private
32
+ * @category Resolve
33
+ */
34
+ export declare function loadBlueprintFile(path: string, options?: LoadBlueprintFileOptions): Promise<LoadedBlueprintFile>;
35
+ /**
36
+ * Read a local blueprint and the ids of the Stack it deploys to
37
+ *
38
+ * Ids come from `overrides`, the environment, `defineBlueprint`, then `.sanity/blueprint.config.json`.
39
+ * Resources are not validated. No network access.
40
+ *
41
+ * @example
42
+ * ```ts
43
+ * import {readBlueprint} from '@sanity/blueprints/resolve'
44
+ *
45
+ * const {resources, resourcesByName, stackId, sources} = await readBlueprint()
46
+ * resources.map((resource) => resource.name)
47
+ * resourcesByName['production-dataset']?.type // 'sanity.project.dataset'
48
+ * sources.stackId // 'config'
49
+ * ```
50
+ * @throws When no blueprint file is found, it cannot be loaded, or `resources` is not an array
51
+ * @category Resolve
52
+ */
53
+ export declare function readBlueprint(options?: ReadBlueprintOptions): Promise<BlueprintInfo>;
@@ -0,0 +1,155 @@
1
+ import { existsSync, readFileSync, statSync } from 'node:fs';
2
+ import { dirname, extname, join, resolve } from 'node:path';
3
+ import { cwd } from 'node:process';
4
+ import { byName } from './by-name.js';
5
+ import { canRetryWithJiti, findJiti, importNative } from './import.js';
6
+ import { readStackConfigFile, resolveStackConfig, stackIdsFromEnv } from './stack-config.js';
7
+ const EXTENSIONS = ['.json', '.js', '.mjs', '.ts'];
8
+ const BASE_NAMES = EXTENSIONS.map((ext) => `blueprint${ext}`);
9
+ /**
10
+ * The file names {@link findBlueprintFile} looks for, in order
11
+ * @internal
12
+ * @private
13
+ * @category Resolve
14
+ */
15
+ export const BLUEPRINT_FILE_NAMES = [...BASE_NAMES, ...BASE_NAMES.map((name) => `sanity.${name}`)];
16
+ /**
17
+ * Find a blueprint file
18
+ *
19
+ * Returns a file path as is. Searches a directory, then its parents, for {@link BLUEPRINT_FILE_NAMES}.
20
+ *
21
+ * @param path A blueprint file or directory. Defaults to the current working directory.
22
+ * @returns The absolute path of the file, or `undefined` when none is found
23
+ * @internal
24
+ * @private
25
+ * @category Resolve
26
+ */
27
+ export function findBlueprintFile(path = cwd()) {
28
+ let dir = resolve(path);
29
+ if (!existsSync(dir))
30
+ return undefined;
31
+ if (statSync(dir).isFile())
32
+ return dir;
33
+ while (true) {
34
+ for (const name of BLUEPRINT_FILE_NAMES) {
35
+ const candidate = join(dir, name);
36
+ if (existsSync(candidate))
37
+ return candidate;
38
+ }
39
+ const parent = dirname(dir);
40
+ if (parent === dir)
41
+ return undefined;
42
+ dir = parent;
43
+ }
44
+ }
45
+ /**
46
+ * Load a blueprint file
47
+ *
48
+ * Parses a JSON file. Imports a JS or TS file and calls its default export.
49
+ * TypeScript that Node cannot run, such as an enum, is loaded with jiti when it is installed.
50
+ * Imported modules are cached, so a later call in the same process does not see changes to the file. Pass a `loader` that skips the cache to re-read it.
51
+ *
52
+ * @param path The blueprint file
53
+ * @throws When the file cannot be loaded or does not produce a blueprint object
54
+ * @internal
55
+ * @private
56
+ * @category Resolve
57
+ */
58
+ export async function loadBlueprintFile(path, options = {}) {
59
+ const extension = extname(path);
60
+ if (extension === '.json') {
61
+ let blueprint;
62
+ try {
63
+ blueprint = JSON.parse(readFileSync(path, 'utf8'));
64
+ }
65
+ catch (error) {
66
+ throw new Error(`Unable to parse ${path}: ${errorText(error)}`, { cause: error });
67
+ }
68
+ return { blueprint: asBlueprint(blueprint, path) };
69
+ }
70
+ if (!EXTENSIONS.includes(extension)) {
71
+ throw new Error(`Unsupported blueprint file extension "${extension}" for ${path}. Expected one of: ${EXTENSIONS.join(', ')}`);
72
+ }
73
+ const defaultExport = await importDefault(path, options.loader);
74
+ if (typeof defaultExport !== 'function') {
75
+ throw new Error(`${path} must export a default function. Wrap the blueprint in defineBlueprint().`);
76
+ }
77
+ const module = defaultExport;
78
+ let blueprint;
79
+ try {
80
+ blueprint = module();
81
+ }
82
+ catch (error) {
83
+ throw new Error(`Error executing the default export of ${path}: ${errorText(error)}`, { cause: error });
84
+ }
85
+ return { blueprint: asBlueprint(blueprint, path), module };
86
+ }
87
+ /**
88
+ * Read a local blueprint and the ids of the Stack it deploys to
89
+ *
90
+ * Ids come from `overrides`, the environment, `defineBlueprint`, then `.sanity/blueprint.config.json`.
91
+ * Resources are not validated. No network access.
92
+ *
93
+ * @example
94
+ * ```ts
95
+ * import {readBlueprint} from '@sanity/blueprints/resolve'
96
+ *
97
+ * const {resources, resourcesByName, stackId, sources} = await readBlueprint()
98
+ * resources.map((resource) => resource.name)
99
+ * resourcesByName['production-dataset']?.type // 'sanity.project.dataset'
100
+ * sources.stackId // 'config'
101
+ * ```
102
+ * @throws When no blueprint file is found, it cannot be loaded, or `resources` is not an array
103
+ * @category Resolve
104
+ */
105
+ export async function readBlueprint(options = {}) {
106
+ const path = findBlueprintFile(options.path);
107
+ if (!path) {
108
+ const searched = resolve(options.path ?? cwd());
109
+ throw new Error(`No blueprint file found in ${searched} or its parent directories. Expected one of: ${BLUEPRINT_FILE_NAMES.join(', ')}`);
110
+ }
111
+ const { blueprint, module } = await loadBlueprintFile(path, { loader: options.loader });
112
+ const resources = blueprint.resources ?? [];
113
+ if (!Array.isArray(resources))
114
+ throw new Error(`Invalid blueprint in ${path}: \`resources\` must be an array`);
115
+ const file = readStackConfigFile(dirname(path));
116
+ const config = resolveStackConfig({
117
+ overrides: options.overrides,
118
+ env: options.env === undefined ? undefined : options.env && stackIdsFromEnv(options.env),
119
+ module,
120
+ config: file,
121
+ });
122
+ return { path, blueprint, module, resources, resourcesByName: byName(resources), ...config, configPath: file?.configPath };
123
+ }
124
+ async function importDefault(path, loader) {
125
+ let error;
126
+ try {
127
+ return await (loader ?? importNative)(path);
128
+ }
129
+ catch (caught) {
130
+ error = caught;
131
+ }
132
+ if (!loader && canRetryWithJiti(error)) {
133
+ const jiti = await findJiti(path);
134
+ if (!jiti)
135
+ throw new Error(`Unable to import ${path}: ${errorText(error)} Install jiti to load it, or pass a loader.`, { cause: error });
136
+ try {
137
+ return await jiti(path);
138
+ }
139
+ catch (caught) {
140
+ error = caught;
141
+ }
142
+ }
143
+ throw new Error(`Unable to import ${path}: ${errorText(error)}`, { cause: error });
144
+ }
145
+ function errorText(error) {
146
+ const message = error instanceof Error ? error.message : String(error);
147
+ return message.endsWith('.') ? message : `${message}.`;
148
+ }
149
+ function asBlueprint(value, path) {
150
+ if (!value || typeof value !== 'object' || Array.isArray(value)) {
151
+ throw new Error(`${path} did not produce a blueprint object`);
152
+ }
153
+ return value;
154
+ }
155
+ //# sourceMappingURL=load.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load.js","sourceRoot":"","sources":["../../src/resolve/load.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAC,MAAM,SAAS,CAAA;AAC1D,OAAO,EAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAC,MAAM,WAAW,CAAA;AACzD,OAAO,EAAC,GAAG,EAAC,M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AAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,GAAG,CAAA;AACxD,CAAC;AAED,SAAS,WAAW,CAAC,KAAc,EAAE,IAAY;IAC/C,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAChE,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,qCAAqC,CAAC,CAAA;IAC/D,CAAC;IACD,OAAO,KAAkB,CAAA;AAC3B,CAAC"}
@@ -0,0 +1,49 @@
1
+ import type { StackConfig, StackConfigFile, StackIdSources, StackIds } from './types.js';
2
+ /**
3
+ * The directory next to the blueprint file that holds the Stack config
4
+ * @internal
5
+ * @private
6
+ * @category Resolve
7
+ */
8
+ export declare const STACK_CONFIG_DIR = ".sanity";
9
+ /**
10
+ * The file in {@link STACK_CONFIG_DIR} that holds the Stack ids
11
+ * @internal
12
+ * @private
13
+ * @category Resolve
14
+ */
15
+ export declare const STACK_CONFIG_FILE = "blueprint.config.json";
16
+ /**
17
+ * Read `.sanity/blueprint.config.json` from a blueprint directory
18
+ * @param dir The blueprint directory. Defaults to the current working directory.
19
+ * @returns The ids in the file and its path, or `undefined` when the file does not exist
20
+ * @throws When the file exists and is not valid JSON
21
+ * @internal
22
+ * @private
23
+ * @category Resolve
24
+ */
25
+ export declare function readStackConfigFile(dir?: string): StackConfigFile | undefined;
26
+ /**
27
+ * Read the Stack ids from `SANITY_ORGANIZATION_ID`, `SANITY_PROJECT_ID`, and `SANITY_BLUEPRINT_STACK_ID`
28
+ * @param env The environment to read. Defaults to `process.env`.
29
+ * @internal
30
+ * @private
31
+ * @category Resolve
32
+ */
33
+ export declare function stackIdsFromEnv(env?: NodeJS.ProcessEnv): StackIds;
34
+ /**
35
+ * Resolve the Stack ids and scope, and which source supplied each id
36
+ *
37
+ * Precedence: `overrides`, `env`, `module`, `config`. The scope is the project if known, else the organization.
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * const config = resolveStackConfig({config: readStackConfigFile()})
42
+ * config.stackId // 'ST-abc123'
43
+ * config.sources.stackId // 'config'
44
+ * ```
45
+ * @internal
46
+ * @private
47
+ * @category Resolve
48
+ */
49
+ export declare function resolveStackConfig(sources?: StackIdSources): StackConfig;