@stripe/extensibility-dev-tools 0.23.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.
Files changed (253) hide show
  1. package/LICENSE.md +19 -0
  2. package/dist/bin/build-custom-object-definitions.cjs +2111 -0
  3. package/dist/bin/build-custom-object-definitions.d.ts +11 -0
  4. package/dist/bin/build-custom-object-definitions.d.ts.map +1 -0
  5. package/dist/bin/build-custom-object-definitions.js +2088 -0
  6. package/dist/bin/create-upload-image.cjs +2136 -0
  7. package/dist/bin/create-upload-image.d.ts +17 -0
  8. package/dist/bin/create-upload-image.d.ts.map +1 -0
  9. package/dist/bin/create-upload-image.js +2113 -0
  10. package/dist/bin/dev-tools-rpc.cjs +3874 -0
  11. package/dist/bin/dev-tools-rpc.d.ts +3 -0
  12. package/dist/bin/dev-tools-rpc.d.ts.map +1 -0
  13. package/dist/bin/dev-tools-rpc.js +3864 -0
  14. package/dist/bin/gen-schemas.cjs +20739 -0
  15. package/dist/bin/gen-schemas.d.ts +8 -0
  16. package/dist/bin/gen-schemas.d.ts.map +1 -0
  17. package/dist/bin/gen-schemas.js +20715 -0
  18. package/dist/bin/gen-workspace.cjs +3847 -0
  19. package/dist/bin/gen-workspace.d.ts +8 -0
  20. package/dist/bin/gen-workspace.d.ts.map +1 -0
  21. package/dist/bin/gen-workspace.js +3841 -0
  22. package/dist/bin/manifest.cjs +686 -0
  23. package/dist/bin/manifest.d.ts +10 -0
  24. package/dist/bin/manifest.d.ts.map +1 -0
  25. package/dist/bin/manifest.js +663 -0
  26. package/dist/bin/rpc/dispatch.d.ts +10 -0
  27. package/dist/bin/rpc/dispatch.d.ts.map +1 -0
  28. package/dist/bin/rpc/handlers.d.ts +4 -0
  29. package/dist/bin/rpc/handlers.d.ts.map +1 -0
  30. package/dist/bin/rpc/types.d.ts +29 -0
  31. package/dist/bin/rpc/types.d.ts.map +1 -0
  32. package/dist/bin/template-info.cjs +1511 -0
  33. package/dist/bin/template-info.d.ts +9 -0
  34. package/dist/bin/template-info.d.ts.map +1 -0
  35. package/dist/bin/template-info.js +1488 -0
  36. package/dist/custom-objects/build-definitions.d.ts +98 -0
  37. package/dist/custom-objects/build-definitions.d.ts.map +1 -0
  38. package/dist/custom-objects/generated/proto/custom_objects/pub/api/app_api/object_definitions_app_service.pb.d.ts +191 -0
  39. package/dist/custom-objects/generated/proto/custom_objects/pub/api/app_api/object_definitions_app_service.pb.d.ts.map +1 -0
  40. package/dist/custom-objects/generated/proto/custom_objects/pub/api/common/schema.pb.d.ts +131 -0
  41. package/dist/custom-objects/generated/proto/custom_objects/pub/api/common/schema.pb.d.ts.map +1 -0
  42. package/dist/custom-objects/generated/proto/google/protobuf/descriptor.pb.d.ts +1482 -0
  43. package/dist/custom-objects/generated/proto/google/protobuf/descriptor.pb.d.ts.map +1 -0
  44. package/dist/custom-objects/generated/proto/google/protobuf/timestamp.pb.d.ts +167 -0
  45. package/dist/custom-objects/generated/proto/google/protobuf/timestamp.pb.d.ts.map +1 -0
  46. package/dist/custom-objects/generated/proto/proto/annotations.pb.d.ts +64 -0
  47. package/dist/custom-objects/generated/proto/proto/annotations.pb.d.ts.map +1 -0
  48. package/dist/custom-objects/generated/proto/proto/extensions.pb.d.ts +657 -0
  49. package/dist/custom-objects/generated/proto/proto/extensions.pb.d.ts.map +1 -0
  50. package/dist/custom-objects/generated/proto/vendor/metadata/pub/api/api_metadata.pb.d.ts +105 -0
  51. package/dist/custom-objects/generated/proto/vendor/metadata/pub/api/api_metadata.pb.d.ts.map +1 -0
  52. package/dist/custom-objects/generated/proto/vendor/net/idempotency/idempotency_model.pb.d.ts +79 -0
  53. package/dist/custom-objects/generated/proto/vendor/net/idempotency/idempotency_model.pb.d.ts.map +1 -0
  54. package/dist/custom-objects/generated/proto/vendor/publicapi/api_group_enum.pb.d.ts +129 -0
  55. package/dist/custom-objects/generated/proto/vendor/publicapi/api_group_enum.pb.d.ts.map +1 -0
  56. package/dist/custom-objects/generated/proto/vendor/publicapi/api_visibility.pb.d.ts +76 -0
  57. package/dist/custom-objects/generated/proto/vendor/publicapi/api_visibility.pb.d.ts.map +1 -0
  58. package/dist/custom-objects/generated/proto/vendor/publicapi/customize_dispatch_middleware_enum.pb.d.ts +78 -0
  59. package/dist/custom-objects/generated/proto/vendor/publicapi/customize_dispatch_middleware_enum.pb.d.ts.map +1 -0
  60. package/dist/custom-objects/generated/proto/vendor/publicapi/docs_namespace_group_enum.pb.d.ts +146 -0
  61. package/dist/custom-objects/generated/proto/vendor/publicapi/docs_namespace_group_enum.pb.d.ts.map +1 -0
  62. package/dist/custom-objects/generated/proto/vendor/publicapi/documented_enum.pb.d.ts +76 -0
  63. package/dist/custom-objects/generated/proto/vendor/publicapi/documented_enum.pb.d.ts.map +1 -0
  64. package/dist/custom-objects/generated/proto/vendor/publicapi/event_scope_enum.pb.d.ts +92 -0
  65. package/dist/custom-objects/generated/proto/vendor/publicapi/event_scope_enum.pb.d.ts.map +1 -0
  66. package/dist/custom-objects/generated/proto/vendor/publicapi/extension_interface.pb.d.ts +124 -0
  67. package/dist/custom-objects/generated/proto/vendor/publicapi/extension_interface.pb.d.ts.map +1 -0
  68. package/dist/custom-objects/generated/proto/vendor/publicapi/feature_enum.pb.d.ts +1070 -0
  69. package/dist/custom-objects/generated/proto/vendor/publicapi/feature_enum.pb.d.ts.map +1 -0
  70. package/dist/custom-objects/generated/proto/vendor/publicapi/field_validation_rules.pb.d.ts +279 -0
  71. package/dist/custom-objects/generated/proto/vendor/publicapi/field_validation_rules.pb.d.ts.map +1 -0
  72. package/dist/custom-objects/generated/proto/vendor/publicapi/flavor_enum.pb.d.ts +78 -0
  73. package/dist/custom-objects/generated/proto/vendor/publicapi/flavor_enum.pb.d.ts.map +1 -0
  74. package/dist/custom-objects/generated/proto/vendor/publicapi/http_error_status.pb.d.ts +102 -0
  75. package/dist/custom-objects/generated/proto/vendor/publicapi/http_error_status.pb.d.ts.map +1 -0
  76. package/dist/custom-objects/generated/proto/vendor/publicapi/method_kind_enum.pb.d.ts +86 -0
  77. package/dist/custom-objects/generated/proto/vendor/publicapi/method_kind_enum.pb.d.ts.map +1 -0
  78. package/dist/custom-objects/generated/proto/vendor/publicapi/method_priority.pb.d.ts +80 -0
  79. package/dist/custom-objects/generated/proto/vendor/publicapi/method_priority.pb.d.ts.map +1 -0
  80. package/dist/custom-objects/generated/proto/vendor/publicapi/permission_check_enum.pb.d.ts +74 -0
  81. package/dist/custom-objects/generated/proto/vendor/publicapi/permission_check_enum.pb.d.ts.map +1 -0
  82. package/dist/custom-objects/generated/proto/vendor/publicapi/redaction_enum.pb.d.ts +76 -0
  83. package/dist/custom-objects/generated/proto/vendor/publicapi/redaction_enum.pb.d.ts.map +1 -0
  84. package/dist/custom-objects/generated/proto/vendor/publicapi/region_routers.pb.d.ts +103 -0
  85. package/dist/custom-objects/generated/proto/vendor/publicapi/region_routers.pb.d.ts.map +1 -0
  86. package/dist/custom-objects/generated/proto/vendor/publicapi/rollout_configs.pb.d.ts +153 -0
  87. package/dist/custom-objects/generated/proto/vendor/publicapi/rollout_configs.pb.d.ts.map +1 -0
  88. package/dist/custom-objects/generated/proto/vendor/publicapi/v2ext.pb.d.ts +1111 -0
  89. package/dist/custom-objects/generated/proto/vendor/publicapi/v2ext.pb.d.ts.map +1 -0
  90. package/dist/custom-objects/generated/proto/vendor/vext/annotations.pb.d.ts +602 -0
  91. package/dist/custom-objects/generated/proto/vendor/vext/annotations.pb.d.ts.map +1 -0
  92. package/dist/custom-objects/generated/proto/vendor/vext/extensions.pb.d.ts +144 -0
  93. package/dist/custom-objects/generated/proto/vendor/vext/extensions.pb.d.ts.map +1 -0
  94. package/dist/custom-objects/generated/proto/vendor/vext/privacy_unified_annotations.pb.d.ts +851 -0
  95. package/dist/custom-objects/generated/proto/vendor/vext/privacy_unified_annotations.pb.d.ts.map +1 -0
  96. package/dist/custom-objects/generated/proto/vendor/vext/xml_annotations.pb.d.ts +125 -0
  97. package/dist/custom-objects/generated/proto/vendor/vext/xml_annotations.pb.d.ts.map +1 -0
  98. package/dist/custom-objects/to-proto-json.d.ts +17 -0
  99. package/dist/custom-objects/to-proto-json.d.ts.map +1 -0
  100. package/dist/dependencies/index.cjs +601 -0
  101. package/dist/dependencies/index.d.ts +320 -0
  102. package/dist/dependencies/index.d.ts.map +1 -0
  103. package/dist/dependencies/index.js +560 -0
  104. package/dist/extensibility-dev-tools-alpha.d.ts +199 -0
  105. package/dist/extensibility-dev-tools-beta.d.ts +199 -0
  106. package/dist/extensibility-dev-tools-dependencies-alpha.d.ts +51 -0
  107. package/dist/extensibility-dev-tools-dependencies-beta.d.ts +51 -0
  108. package/dist/extensibility-dev-tools-dependencies-internal.d.ts +372 -0
  109. package/dist/extensibility-dev-tools-dependencies-public.d.ts +51 -0
  110. package/dist/extensibility-dev-tools-internal.d.ts +1722 -0
  111. package/dist/extensibility-dev-tools-jsonschema-tools-alpha.d.ts +57 -0
  112. package/dist/extensibility-dev-tools-jsonschema-tools-beta.d.ts +57 -0
  113. package/dist/extensibility-dev-tools-jsonschema-tools-internal.d.ts +123 -0
  114. package/dist/extensibility-dev-tools-jsonschema-tools-public.d.ts +57 -0
  115. package/dist/extensibility-dev-tools-manifest-alpha.d.ts +31 -0
  116. package/dist/extensibility-dev-tools-manifest-beta.d.ts +31 -0
  117. package/dist/extensibility-dev-tools-manifest-internal.d.ts +461 -0
  118. package/dist/extensibility-dev-tools-manifest-public.d.ts +31 -0
  119. package/dist/extensibility-dev-tools-public.d.ts +199 -0
  120. package/dist/extensibility-dev-tools-schemas-alpha.d.ts +9 -0
  121. package/dist/extensibility-dev-tools-schemas-beta.d.ts +9 -0
  122. package/dist/extensibility-dev-tools-schemas-internal.d.ts +41 -0
  123. package/dist/extensibility-dev-tools-schemas-public.d.ts +9 -0
  124. package/dist/extensibility-dev-tools-templates-alpha.d.ts +67 -0
  125. package/dist/extensibility-dev-tools-templates-beta.d.ts +67 -0
  126. package/dist/extensibility-dev-tools-templates-internal.d.ts +554 -0
  127. package/dist/extensibility-dev-tools-templates-public.d.ts +67 -0
  128. package/dist/extensibility-dev-tools-workspace-alpha.d.ts +51 -0
  129. package/dist/extensibility-dev-tools-workspace-beta.d.ts +51 -0
  130. package/dist/extensibility-dev-tools-workspace-internal.d.ts +410 -0
  131. package/dist/extensibility-dev-tools-workspace-public.d.ts +51 -0
  132. package/dist/index.cjs +3810 -0
  133. package/dist/index.d.ts +18 -0
  134. package/dist/index.d.ts.map +1 -0
  135. package/dist/index.js +3758 -0
  136. package/dist/jsonschema-tools.cjs +20451 -0
  137. package/dist/jsonschema-tools.d.ts +98 -0
  138. package/dist/jsonschema-tools.d.ts.map +1 -0
  139. package/dist/jsonschema-tools.js +20404 -0
  140. package/dist/manifest/index.cjs +610 -0
  141. package/dist/manifest/index.d.ts +8 -0
  142. package/dist/manifest/index.d.ts.map +1 -0
  143. package/dist/manifest/index.js +571 -0
  144. package/dist/manifest/manifest-v1.d.ts +102 -0
  145. package/dist/manifest/manifest-v1.d.ts.map +1 -0
  146. package/dist/manifest/manifest-v2.d.ts +253 -0
  147. package/dist/manifest/manifest-v2.d.ts.map +1 -0
  148. package/dist/manifest/stripe-app-manifest.d.ts +114 -0
  149. package/dist/manifest/stripe-app-manifest.d.ts.map +1 -0
  150. package/dist/schemas/index.cjs +20692 -0
  151. package/dist/schemas/index.d.ts +37 -0
  152. package/dist/schemas/index.d.ts.map +1 -0
  153. package/dist/schemas/index.js +20656 -0
  154. package/dist/templates/diff-viewer/diff-generator.d.ts +22 -0
  155. package/dist/templates/diff-viewer/diff-generator.d.ts.map +1 -0
  156. package/dist/templates/diff-viewer/diff-prompt.d.ts +13 -0
  157. package/dist/templates/diff-viewer/diff-prompt.d.ts.map +1 -0
  158. package/dist/templates/diff-viewer/index.d.ts +7 -0
  159. package/dist/templates/diff-viewer/index.d.ts.map +1 -0
  160. package/dist/templates/diff-viewer/terminal-renderer.d.ts +29 -0
  161. package/dist/templates/diff-viewer/terminal-renderer.d.ts.map +1 -0
  162. package/dist/templates/diff-viewer/types.d.ts +58 -0
  163. package/dist/templates/diff-viewer/types.d.ts.map +1 -0
  164. package/dist/templates/extensions/base.d.ts +23 -0
  165. package/dist/templates/extensions/base.d.ts.map +1 -0
  166. package/dist/templates/extensions/billing.bill.discount_calculation.d.ts +6 -0
  167. package/dist/templates/extensions/billing.bill.discount_calculation.d.ts.map +1 -0
  168. package/dist/templates/extensions/billing.customer_balance_application.d.ts +6 -0
  169. package/dist/templates/extensions/billing.customer_balance_application.d.ts.map +1 -0
  170. package/dist/templates/extensions/billing.invoice_collection_setting.d.ts +6 -0
  171. package/dist/templates/extensions/billing.invoice_collection_setting.d.ts.map +1 -0
  172. package/dist/templates/extensions/billing.prorations.d.ts +6 -0
  173. package/dist/templates/extensions/billing.prorations.d.ts.map +1 -0
  174. package/dist/templates/extensions/billing.recurring_billing_item_handling.d.ts +6 -0
  175. package/dist/templates/extensions/billing.recurring_billing_item_handling.d.ts.map +1 -0
  176. package/dist/templates/extensions/core.workflows.custom_action.d.ts +6 -0
  177. package/dist/templates/extensions/core.workflows.custom_action.d.ts.map +1 -0
  178. package/dist/templates/extensions/extend.objects.custom_objects.d.ts +6 -0
  179. package/dist/templates/extensions/extend.objects.custom_objects.d.ts.map +1 -0
  180. package/dist/templates/extensions/extend.workflows.custom_action.d.ts +6 -0
  181. package/dist/templates/extensions/extend.workflows.custom_action.d.ts.map +1 -0
  182. package/dist/templates/extensions/index.d.ts +13 -0
  183. package/dist/templates/extensions/index.d.ts.map +1 -0
  184. package/dist/templates/extensions/registry.d.ts +10 -0
  185. package/dist/templates/extensions/registry.d.ts.map +1 -0
  186. package/dist/templates/extensions/types.d.ts +104 -0
  187. package/dist/templates/extensions/types.d.ts.map +1 -0
  188. package/dist/templates/file-writer.d.ts +140 -0
  189. package/dist/templates/file-writer.d.ts.map +1 -0
  190. package/dist/templates/fs/_impl.d.ts +29 -0
  191. package/dist/templates/fs/_impl.d.ts.map +1 -0
  192. package/dist/templates/fs/filesystem.d.ts +8 -0
  193. package/dist/templates/fs/filesystem.d.ts.map +1 -0
  194. package/dist/templates/fs/in-memory.d.ts +9 -0
  195. package/dist/templates/fs/in-memory.d.ts.map +1 -0
  196. package/dist/templates/fs/index.d.ts +25 -0
  197. package/dist/templates/fs/index.d.ts.map +1 -0
  198. package/dist/templates/fs-utils.d.ts +17 -0
  199. package/dist/templates/fs-utils.d.ts.map +1 -0
  200. package/dist/templates/index.cjs +2248 -0
  201. package/dist/templates/index.d.ts +32 -0
  202. package/dist/templates/index.d.ts.map +1 -0
  203. package/dist/templates/index.js +2203 -0
  204. package/dist/templates/root/index.d.ts +60 -0
  205. package/dist/templates/root/index.d.ts.map +1 -0
  206. package/dist/templates/simple-templates.d.ts +8 -0
  207. package/dist/templates/simple-templates.d.ts.map +1 -0
  208. package/dist/templates/template-manager.d.ts +8 -0
  209. package/dist/templates/template-manager.d.ts.map +1 -0
  210. package/dist/templates/types.d.ts +9 -0
  211. package/dist/templates/types.d.ts.map +1 -0
  212. package/dist/tsconfig.build.tsbuildinfo +1 -0
  213. package/dist/workspace/index.cjs +3756 -0
  214. package/dist/workspace/index.d.ts +336 -0
  215. package/dist/workspace/index.d.ts.map +1 -0
  216. package/dist/workspace/index.js +3731 -0
  217. package/package.json +137 -0
  218. package/templates/extensions/billing.bill.discount_calculation/index.test.ts +15 -0
  219. package/templates/extensions/billing.bill.discount_calculation/index.ts +20 -0
  220. package/templates/extensions/billing.customer_balance_application/index.test.ts +15 -0
  221. package/templates/extensions/billing.customer_balance_application/index.ts +18 -0
  222. package/templates/extensions/billing.invoice_collection_setting/index.test.ts +15 -0
  223. package/templates/extensions/billing.invoice_collection_setting/index.ts +16 -0
  224. package/templates/extensions/billing.prorations/index.test.ts +15 -0
  225. package/templates/extensions/billing.prorations/index.ts +18 -0
  226. package/templates/extensions/billing.recurring_billing_item_handling/index.test.ts +15 -0
  227. package/templates/extensions/billing.recurring_billing_item_handling/index.ts +42 -0
  228. package/templates/extensions/common/.prettierignore +3 -0
  229. package/templates/extensions/common/eslint.config.mts.mustache +95 -0
  230. package/templates/extensions/common/package.json.mustache +26 -0
  231. package/templates/extensions/common/tsconfig.build.json.mustache +15 -0
  232. package/templates/extensions/common/tsconfig.json.mustache +16 -0
  233. package/templates/extensions/core.workflows.custom_action/custom_input.schema.json +6 -0
  234. package/templates/extensions/core.workflows.custom_action/index.test.ts +15 -0
  235. package/templates/extensions/core.workflows.custom_action/index.ts +31 -0
  236. package/templates/extensions/extend.workflows.custom_action/custom_input.schema.json +6 -0
  237. package/templates/extensions/extend.workflows.custom_action/index.test.ts +15 -0
  238. package/templates/extensions/extend.workflows.custom_action/index.ts +31 -0
  239. package/templates/root/.husky/pre-commit +1 -0
  240. package/templates/root/.prettierignore +5 -0
  241. package/templates/root/.prettierrc +7 -0
  242. package/templates/root/_gitignore +28 -0
  243. package/templates/root/custom-objects/package.json +20 -0
  244. package/templates/root/custom-objects/tsconfig.json +9 -0
  245. package/templates/root/eslint.config.mts +95 -0
  246. package/templates/root/package.json.mustache +32 -0
  247. package/templates/root/pnpm-workspace.yaml +7 -0
  248. package/templates/root/stripe-app.yaml.mustache +6 -0
  249. package/templates/root/tools/test.mts +38 -0
  250. package/templates/root/tsconfig.base.json +23 -0
  251. package/templates/root/tsconfig.json +15 -0
  252. package/templates/root/ui/package.json +17 -0
  253. package/templates/root/vitest.config.mts +47 -0
@@ -0,0 +1,686 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
18
+ // If the importer is in node compatibility mode or this is not an ESM
19
+ // file that has been converted to a CommonJS file using a Babel-
20
+ // compatible transform (i.e. "__esModule" has not been set), then set
21
+ // "default" to the CommonJS "module.exports" for node compatibility.
22
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
23
+ mod
24
+ ));
25
+
26
+ // src/bin/manifest.ts
27
+ var import_yargs = __toESM(require("yargs"), 1);
28
+ var import_helpers = require("yargs/helpers");
29
+ var import_extensibility_tool_utils3 = require("@stripe/extensibility-tool-utils");
30
+
31
+ // src/manifest/stripe-app-manifest.ts
32
+ var import_extensibility_tool_utils2 = require("@stripe/extensibility-tool-utils");
33
+
34
+ // src/manifest/manifest-v1.ts
35
+ var import_fs = require("fs");
36
+ function formatCustomObjectEntry(entry) {
37
+ return `${entry.filePath}#${entry.className}`;
38
+ }
39
+ function parseCustomObjectEntry(entryString) {
40
+ const parts = entryString.split("#");
41
+ if (parts.length !== 2) {
42
+ throw new Error(
43
+ `Invalid object entry format: ${entryString}. Expected format: "path/to/file.d.ts#ClassName"`
44
+ );
45
+ }
46
+ const [filePath, className] = parts;
47
+ if (!filePath || !className) {
48
+ throw new Error(
49
+ `Invalid object entry format: ${entryString}. Expected format: "path/to/file.d.ts#ClassName"`
50
+ );
51
+ }
52
+ return { filePath, className };
53
+ }
54
+ var _ManifestV1 = class __ManifestV1 {
55
+ constructor(filePath, data) {
56
+ this.filePath = filePath;
57
+ this.data = data;
58
+ }
59
+ /**
60
+ * Load stripe-app.json from disk
61
+ * @param filePath - Path to stripe-app.json
62
+ * @throws Error if file is invalid or cannot be read
63
+ */
64
+ static load(filePath) {
65
+ if (!(0, import_fs.existsSync)(filePath)) {
66
+ throw new Error(`Manifest file not found: ${filePath}`);
67
+ }
68
+ const content = (0, import_fs.readFileSync)(filePath, "utf-8");
69
+ const data = JSON.parse(content);
70
+ if (!data.id) {
71
+ throw new Error('Manifest must contain "id" field');
72
+ }
73
+ return new __ManifestV1(filePath, data);
74
+ }
75
+ /**
76
+ * Get the app ID from the manifest
77
+ */
78
+ getAppId() {
79
+ return this.data.id;
80
+ }
81
+ /**
82
+ * Get the app name from the manifest
83
+ */
84
+ getAppName() {
85
+ return this.data.name;
86
+ }
87
+ /**
88
+ * Get all custom objects as structured entries
89
+ */
90
+ getCustomObjects() {
91
+ const entries = [];
92
+ if (this.data.exported_custom_objects) {
93
+ for (const entry of this.data.exported_custom_objects) {
94
+ entries.push(parseCustomObjectEntry(entry));
95
+ }
96
+ }
97
+ return entries;
98
+ }
99
+ /**
100
+ * Check if a custom object entry exists in the manifest
101
+ */
102
+ hasCustomObject(entry) {
103
+ const objects = this.getCustomObjects();
104
+ return objects.some(
105
+ (existing) => existing.filePath === entry.filePath && existing.className === entry.className
106
+ );
107
+ }
108
+ /**
109
+ * Add a custom object entry to the manifest
110
+ * Does nothing if entry already exists
111
+ * @returns true if entry was added, false if it already existed
112
+ */
113
+ addCustomObject(entry) {
114
+ if (this.hasCustomObject(entry)) {
115
+ return false;
116
+ }
117
+ const entryString = formatCustomObjectEntry(entry);
118
+ this.data.exported_custom_objects ??= [];
119
+ this.data.exported_custom_objects.push(entryString);
120
+ return true;
121
+ }
122
+ /**
123
+ * Remove a custom object entry from the manifest
124
+ * @returns true if entry was removed, false if it didn't exist
125
+ */
126
+ removeCustomObject(entry) {
127
+ if (!this.data.exported_custom_objects) {
128
+ return false;
129
+ }
130
+ const entryString = formatCustomObjectEntry(entry);
131
+ const originalLength = this.data.exported_custom_objects.length;
132
+ this.data.exported_custom_objects = this.data.exported_custom_objects.filter(
133
+ (e) => e !== entryString
134
+ );
135
+ if (this.data.exported_custom_objects.length === 0) {
136
+ delete this.data.exported_custom_objects;
137
+ }
138
+ return this.data.exported_custom_objects?.length !== originalLength;
139
+ }
140
+ /**
141
+ * Get the raw manifest data (for reading other fields)
142
+ */
143
+ getRawData() {
144
+ return this.data;
145
+ }
146
+ /**
147
+ * Save changes back to disk
148
+ */
149
+ save() {
150
+ (0, import_fs.writeFileSync)(this.filePath, JSON.stringify(this.data, null, 2) + "\n");
151
+ }
152
+ };
153
+
154
+ // src/manifest/manifest-v2.ts
155
+ var import_promises = require("fs/promises");
156
+ var yaml = __toESM(require("yaml"), 1);
157
+ var import_extensibility_tool_utils = require("@stripe/extensibility-tool-utils");
158
+ function isNonEmptyString(value) {
159
+ return typeof value === "string" && value.trim().length > 0;
160
+ }
161
+ function isYamlObject(value) {
162
+ return typeof value === "object" && value !== null && !Array.isArray(value);
163
+ }
164
+ function validateManifestV2Data(data) {
165
+ if (!isNonEmptyString(data.id)) {
166
+ throw new Error('Manifest must contain non-empty "id" field');
167
+ }
168
+ if (!isNonEmptyString(data.name)) {
169
+ throw new Error('Manifest must contain non-empty "name" field');
170
+ }
171
+ if (!isNonEmptyString(data.version)) {
172
+ throw new Error('Manifest must contain non-empty "version" field');
173
+ }
174
+ if ("extensions" in data && !Array.isArray(data.extensions)) {
175
+ throw new Error('Manifest field "extensions" must be an array when provided');
176
+ }
177
+ if ("custom_object_definitions" in data && !isYamlObject(data.custom_object_definitions)) {
178
+ throw new Error(
179
+ 'Manifest field "custom_object_definitions" must be an object with a "definitions" array'
180
+ );
181
+ }
182
+ const coBlock = data.custom_object_definitions;
183
+ const definitions = isYamlObject(coBlock) ? coBlock.definitions : void 0;
184
+ if (!definitions) {
185
+ return;
186
+ }
187
+ if (!Array.isArray(definitions)) {
188
+ throw new Error(
189
+ 'Manifest field "custom_object_definitions.definitions" must be an array'
190
+ );
191
+ }
192
+ for (let i = 0; i < definitions.length; i++) {
193
+ const def = definitions[i];
194
+ const prefix = `custom_object_definitions.definitions[${String(i)}]`;
195
+ if (!isYamlObject(def) || !isNonEmptyString(def.id)) {
196
+ throw new Error(
197
+ `${prefix}: missing or invalid "id" field. Got: ${JSON.stringify(def)}`
198
+ );
199
+ }
200
+ if (!isYamlObject(def.specification)) {
201
+ throw new Error(
202
+ `${prefix}: missing or invalid "specification" field. Expected: { type: "typescript", content: "path/to/file.ts" }. Got: ${JSON.stringify(def)}`
203
+ );
204
+ }
205
+ if (!isNonEmptyString(def.specification.type)) {
206
+ throw new Error(
207
+ `${prefix}: missing or invalid "specification.type" field. Got: ${JSON.stringify(def)}`
208
+ );
209
+ }
210
+ if (!isNonEmptyString(def.specification.content)) {
211
+ throw new Error(
212
+ `${prefix}: missing or invalid "specification.content" field. Got: ${JSON.stringify(def)}`
213
+ );
214
+ }
215
+ }
216
+ }
217
+ var _ManifestV2 = class __ManifestV2 {
218
+ constructor(filePath, data) {
219
+ this.filePath = filePath;
220
+ this.data = data;
221
+ }
222
+ /**
223
+ * Load stripe-app.yaml from disk
224
+ * @param filePath - Path to stripe-app.yaml
225
+ * @throws Error if file is invalid or cannot be read
226
+ */
227
+ static async load(filePath) {
228
+ try {
229
+ const content = await (0, import_promises.readFile)(filePath, "utf-8");
230
+ const parsed = yaml.parse(content);
231
+ if (!isYamlObject(parsed)) {
232
+ throw new Error("Invalid stripe-app.yaml format: root must be an object");
233
+ }
234
+ validateManifestV2Data(parsed);
235
+ const data = parsed;
236
+ data.extensions ??= [];
237
+ return new __ManifestV2(filePath, data);
238
+ } catch (err) {
239
+ if (err instanceof Error) {
240
+ throw new Error(`Error reading stripe-app.yaml: ${err.message}`);
241
+ }
242
+ throw new Error(`Error reading stripe-app.yaml: ${String(err)}`);
243
+ }
244
+ }
245
+ /**
246
+ * Get the app ID from the manifest
247
+ */
248
+ getAppId() {
249
+ return this.data.id;
250
+ }
251
+ /**
252
+ * Get the app name from the manifest
253
+ */
254
+ getAppName() {
255
+ return this.data.name;
256
+ }
257
+ // ============================================================
258
+ // Custom Objects
259
+ // ============================================================
260
+ /**
261
+ * Get all custom object definitions, parsed into internal format.
262
+ * Entries are guaranteed structurally valid by load-time validation.
263
+ */
264
+ getCustomObjects() {
265
+ const definitions = this.data.custom_object_definitions?.definitions;
266
+ if (!definitions || definitions.length === 0) {
267
+ return [];
268
+ }
269
+ return definitions.map((def) => ({
270
+ id: def.id,
271
+ type: def.specification.type,
272
+ path: def.specification.content,
273
+ name: (0, import_extensibility_tool_utils._toPascalCase)(def.id)
274
+ }));
275
+ }
276
+ /**
277
+ * Check if a custom object exists by id
278
+ */
279
+ hasCustomObject(id) {
280
+ const definitions = this.data.custom_object_definitions?.definitions;
281
+ if (!definitions) return false;
282
+ return definitions.some((def) => def.id === id);
283
+ }
284
+ /**
285
+ * Add a custom object definition.
286
+ *
287
+ * Identity is keyed on `id` alone. The export name is derived via
288
+ * `_toPascalCase(id)` at read time, so `id` should be valid snake_case
289
+ * (e.g., "device", "loyalty_card", "http_request").
290
+ *
291
+ * @param id - Object identifier (e.g., "device", "loyalty_card")
292
+ * @param content - Path to the definition file (e.g., "src/device.object.ts")
293
+ * @param type - Specification type, defaults to "typescript"
294
+ * @returns true if added, false if already exists
295
+ */
296
+ addCustomObject(id, content, type = "typescript") {
297
+ if (this.hasCustomObject(id)) {
298
+ return false;
299
+ }
300
+ this.data.custom_object_definitions ??= {};
301
+ this.data.custom_object_definitions.definitions ??= [];
302
+ this.data.custom_object_definitions.definitions.push({
303
+ id,
304
+ specification: { type, content }
305
+ });
306
+ return true;
307
+ }
308
+ /**
309
+ * Remove a custom object definition by id
310
+ * @param id - Object identifier to remove
311
+ * @returns true if removed, false if not found
312
+ */
313
+ removeCustomObject(id) {
314
+ const block = this.data.custom_object_definitions;
315
+ if (!block?.definitions) {
316
+ return false;
317
+ }
318
+ const originalLength = block.definitions.length;
319
+ block.definitions = block.definitions.filter((def) => def.id !== id);
320
+ const newLength = block.definitions.length;
321
+ if (newLength === 0) {
322
+ delete this.data.custom_object_definitions;
323
+ }
324
+ return newLength < originalLength;
325
+ }
326
+ // ============================================================
327
+ // Extensions
328
+ // ============================================================
329
+ /**
330
+ * Add a new extension or update an existing one by ID
331
+ * If an extension with the provided ID exists, it will be replaced entirely
332
+ * @param extension - Extension configuration with all required fields including id
333
+ * @returns The extension ID
334
+ */
335
+ addOrUpdateExtension(extension) {
336
+ const newExtension = {
337
+ id: extension.id,
338
+ name: extension.name,
339
+ interface_id: extension.interface_id,
340
+ version: extension.version,
341
+ ...extension.description !== void 0 && {
342
+ description: extension.description
343
+ },
344
+ ...extension.stripe_version !== void 0 && {
345
+ stripe_version: extension.stripe_version
346
+ },
347
+ ...extension.script_entry_point !== void 0 && {
348
+ script_entry_point: extension.script_entry_point
349
+ },
350
+ ...extension.script !== void 0 && { script: extension.script },
351
+ permissions: extension.permissions,
352
+ methods: extension.methods,
353
+ ...extension.configuration !== void 0 && {
354
+ configuration: extension.configuration
355
+ },
356
+ ...extension.endpoints !== void 0 && {
357
+ endpoints: extension.endpoints
358
+ }
359
+ };
360
+ this.data.extensions ??= [];
361
+ const existingIndex = this.data.extensions.findIndex(
362
+ (ext) => ext.id === extension.id
363
+ );
364
+ if (existingIndex !== -1) {
365
+ this.data.extensions[existingIndex] = newExtension;
366
+ } else {
367
+ this.data.extensions.push(newExtension);
368
+ }
369
+ return extension.id;
370
+ }
371
+ /**
372
+ * Get a read-only view of all extensions
373
+ */
374
+ getExtensions() {
375
+ return this.data.extensions ?? [];
376
+ }
377
+ /**
378
+ * Get the raw manifest data (for reading other fields)
379
+ */
380
+ getRawData() {
381
+ return this.data;
382
+ }
383
+ /**
384
+ * Save changes back to disk
385
+ * @throws Error if file cannot be written
386
+ */
387
+ async save() {
388
+ try {
389
+ const updatedContent = yaml.stringify(this.data);
390
+ await (0, import_promises.writeFile)(this.filePath, updatedContent, "utf-8");
391
+ } catch (err) {
392
+ if (err instanceof Error) {
393
+ throw new Error(`Error writing stripe-app.yaml: ${err.message}`);
394
+ }
395
+ throw new Error(`Error writing stripe-app.yaml: ${String(err)}`);
396
+ }
397
+ }
398
+ };
399
+
400
+ // src/manifest/stripe-app-manifest.ts
401
+ var _StripeAppManifest = class __StripeAppManifest {
402
+ constructor(manifestPath, version, v1, v2) {
403
+ this.manifestPath = manifestPath;
404
+ this.version = version;
405
+ this.v1 = v1;
406
+ this.v2 = v2;
407
+ }
408
+ /**
409
+ * Load a manifest file, automatically detecting the version.
410
+ * @param manifestPath - Path to stripe-app.json or stripe-app.yaml
411
+ * @returns Loaded manifest instance
412
+ */
413
+ static async load(manifestPath) {
414
+ const version = __StripeAppManifest.detectVersion(manifestPath);
415
+ if (version === "v1") {
416
+ const reader = _ManifestV1.load(manifestPath);
417
+ return new __StripeAppManifest(manifestPath, version, reader, null);
418
+ } else {
419
+ const reader = await _ManifestV2.load(manifestPath);
420
+ return new __StripeAppManifest(manifestPath, version, null, reader);
421
+ }
422
+ }
423
+ /**
424
+ * Detect manifest version from file path.
425
+ * TODO: Add content-based detection if needed.
426
+ */
427
+ static detectVersion(manifestPath) {
428
+ const lowerPath = manifestPath.toLowerCase();
429
+ if (lowerPath.endsWith(".yaml") || lowerPath.endsWith(".yml")) {
430
+ return "v2";
431
+ }
432
+ if (lowerPath.endsWith(".json")) {
433
+ return "v1";
434
+ }
435
+ throw new Error(
436
+ `Cannot detect manifest version from path: ${manifestPath}. Expected .json (v1) or .yaml/.yml (v2) extension.`
437
+ );
438
+ }
439
+ /**
440
+ * Get the detected manifest version
441
+ */
442
+ getVersion() {
443
+ return this.version;
444
+ }
445
+ /**
446
+ * Get the manifest file path
447
+ */
448
+ getManifestPath() {
449
+ return this.manifestPath;
450
+ }
451
+ // ============================================================
452
+ // App Metadata (supported by both V1 and V2)
453
+ // ============================================================
454
+ /**
455
+ * Get the app ID from the manifest
456
+ */
457
+ getAppId() {
458
+ if (this.v1) {
459
+ return this.v1.getAppId();
460
+ }
461
+ if (this.v2) {
462
+ return this.v2.getAppId();
463
+ }
464
+ return void 0;
465
+ }
466
+ /**
467
+ * Get the app name from the manifest
468
+ */
469
+ getAppName() {
470
+ if (this.v1) {
471
+ return this.v1.getAppName();
472
+ }
473
+ if (this.v2) {
474
+ return this.v2.getAppName();
475
+ }
476
+ return void 0;
477
+ }
478
+ // ============================================================
479
+ // Custom Objects (supported by both V1 and V2)
480
+ // ============================================================
481
+ /**
482
+ * Get all custom objects from the manifest
483
+ */
484
+ getCustomObjects() {
485
+ if (this.v1) {
486
+ return this.v1.getCustomObjects();
487
+ }
488
+ if (this.v2) {
489
+ return this.v2.getCustomObjects().map((obj) => ({
490
+ filePath: obj.path,
491
+ className: obj.name
492
+ }));
493
+ }
494
+ return [];
495
+ }
496
+ /**
497
+ * Check if a custom object entry exists in the manifest.
498
+ *
499
+ * **V2 note:** Identity is keyed on `_toSnakeCase(className)` alone — `filePath`
500
+ * is not considered. Two entries with the same class name but different file
501
+ * paths are treated as the same object. The `_toSnakeCase` → `_toPascalCase`
502
+ * round-trip is lossless for typical class names but lossy for consecutive
503
+ * uppercase (e.g., `HTTPClient` → `http_client` → `HttpClient`). The manifest
504
+ * `id` field is the source of truth; see `_CustomObjectDefinitionYaml` docs.
505
+ */
506
+ hasCustomObject(entry) {
507
+ if (this.v1) {
508
+ return this.v1.hasCustomObject(entry);
509
+ }
510
+ if (this.v2) {
511
+ return this.v2.hasCustomObject((0, import_extensibility_tool_utils2._toSnakeCase)(entry.className));
512
+ }
513
+ return false;
514
+ }
515
+ /**
516
+ * Add a custom object entry to the manifest.
517
+ *
518
+ * **V2 note:** The manifest `id` is derived as `_toSnakeCase(className)` and
519
+ * `filePath` is stored as the specification `content` path. Identity/dedup
520
+ * is based on `id` alone — see `hasCustomObject` for details.
521
+ *
522
+ * @param entry - The custom object entry to add
523
+ * @returns true if entry was added, false if it already existed
524
+ */
525
+ addCustomObject(entry) {
526
+ if (this.v1) {
527
+ return this.v1.addCustomObject(entry);
528
+ }
529
+ if (this.v2) {
530
+ return this.v2.addCustomObject((0, import_extensibility_tool_utils2._toSnakeCase)(entry.className), entry.filePath);
531
+ }
532
+ return false;
533
+ }
534
+ /**
535
+ * Remove a custom object entry from the manifest.
536
+ *
537
+ * **V2 note:** Removal is keyed on `_toSnakeCase(className)` — `filePath` is
538
+ * not considered. See `hasCustomObject` for identity semantics.
539
+ *
540
+ * @param entry - The custom object entry to remove
541
+ * @returns true if entry was removed, false if it didn't exist
542
+ */
543
+ removeCustomObject(entry) {
544
+ if (this.v1) {
545
+ return this.v1.removeCustomObject(entry);
546
+ }
547
+ if (this.v2) {
548
+ return this.v2.removeCustomObject((0, import_extensibility_tool_utils2._toSnakeCase)(entry.className));
549
+ }
550
+ return false;
551
+ }
552
+ // ============================================================
553
+ // Extensions (V2 only)
554
+ // ============================================================
555
+ /**
556
+ * Get all extensions from the manifest
557
+ * @throws Error if manifest version doesn't support extensions
558
+ */
559
+ getExtensions() {
560
+ if (this.v2) {
561
+ return this.v2.getExtensions();
562
+ }
563
+ throw new Error("Extensions are not supported in V1 manifests (stripe-app.json)");
564
+ }
565
+ /**
566
+ * Add or update an extension in the manifest.
567
+ * If an extension with the same ID exists, it will be replaced.
568
+ *
569
+ * @param config - Full extension configuration
570
+ * @returns The extension ID
571
+ * @throws Error if manifest version doesn't support extensions
572
+ */
573
+ addOrUpdateExtension(config) {
574
+ if (this.v2) {
575
+ return this.v2.addOrUpdateExtension(config);
576
+ }
577
+ throw new Error("Extensions are not supported in V1 manifests (stripe-app.json)");
578
+ }
579
+ // ============================================================
580
+ // Persistence
581
+ // ============================================================
582
+ /**
583
+ * Save changes back to disk
584
+ */
585
+ async save() {
586
+ if (this.v1) {
587
+ this.v1.save();
588
+ return;
589
+ }
590
+ if (this.v2) {
591
+ await this.v2.save();
592
+ return;
593
+ }
594
+ throw new Error("No reader loaded - this should never happen");
595
+ }
596
+ };
597
+
598
+ // src/bin/manifest.ts
599
+ var logger = (0, import_extensibility_tool_utils3._createLogger)({ name: "manifest" });
600
+ function requireV2Manifest(manifestPath) {
601
+ const lower = manifestPath.toLowerCase();
602
+ if (!lower.endsWith(".yaml") && !lower.endsWith(".yml")) {
603
+ throw new Error(
604
+ `This CLI requires a V2 manifest (stripe-app.yaml). Got: ${manifestPath}`
605
+ );
606
+ }
607
+ }
608
+ async function main() {
609
+ await (0, import_yargs.default)((0, import_helpers.hideBin)(process.argv)).usage("Manage Stripe app manifests").help().version(false).demandCommand(1, "Specify a subcommand: read, add-custom-object").command(
610
+ "read",
611
+ "Read manifest contents",
612
+ (y) => y.option("path", {
613
+ type: "string",
614
+ description: "Path to stripe-app.yaml (V2 manifest)",
615
+ demandOption: true
616
+ }).option("output-path", {
617
+ type: "string",
618
+ description: "Write JSON result to this file instead of stdout"
619
+ }),
620
+ async (args) => {
621
+ requireV2Manifest(args.path);
622
+ const manifest = await _StripeAppManifest.load(args.path);
623
+ const result = {
624
+ appId: manifest.getAppId(),
625
+ appName: manifest.getAppName(),
626
+ customObjects: manifest.getCustomObjects()
627
+ };
628
+ if (args.outputPath) {
629
+ (0, import_extensibility_tool_utils3._writeJsonOutput)(args.outputPath, result);
630
+ } else {
631
+ process.stdout.write(JSON.stringify(result, null, 2) + "\n");
632
+ }
633
+ }
634
+ ).command(
635
+ "add-custom-object",
636
+ "Add or update a custom object in the manifest (idempotent)",
637
+ (y) => y.option("path", {
638
+ type: "string",
639
+ description: "Path to stripe-app.yaml (V2 manifest)",
640
+ demandOption: true
641
+ }).option("file-path", {
642
+ type: "string",
643
+ description: "Source file path of the custom object",
644
+ demandOption: true
645
+ }).option("class-name", {
646
+ type: "string",
647
+ description: "Class name of the custom object",
648
+ demandOption: true
649
+ }).option("output-path", {
650
+ type: "string",
651
+ description: "Write JSON result to this file instead of stdout"
652
+ }),
653
+ async (args) => {
654
+ requireV2Manifest(args.path);
655
+ const manifest = await _StripeAppManifest.load(args.path);
656
+ const entry = {
657
+ filePath: args.filePath,
658
+ className: args.className
659
+ };
660
+ let outcome;
661
+ const existing = manifest.getCustomObjects().find((co) => co.className === entry.className);
662
+ if (existing?.filePath === entry.filePath) {
663
+ outcome = "unchanged";
664
+ } else if (existing) {
665
+ manifest.removeCustomObject(existing);
666
+ manifest.addCustomObject(entry);
667
+ await manifest.save();
668
+ outcome = "updated";
669
+ } else {
670
+ manifest.addCustomObject(entry);
671
+ await manifest.save();
672
+ outcome = "added";
673
+ }
674
+ const result = { outcome };
675
+ if (args.outputPath) {
676
+ (0, import_extensibility_tool_utils3._writeJsonOutput)(args.outputPath, result);
677
+ } else {
678
+ process.stdout.write(JSON.stringify(result, null, 2) + "\n");
679
+ }
680
+ }
681
+ ).parse();
682
+ }
683
+ main().catch((err) => {
684
+ logger.error({ err }, "Unexpected error");
685
+ process.exit(1);
686
+ });
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Manage Stripe app manifests.
4
+ *
5
+ * Subcommands:
6
+ * read — Read manifest contents
7
+ * add-custom-object — Idempotent upsert of a custom object entry
8
+ */
9
+ export {};
10
+ //# sourceMappingURL=manifest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../src/bin/manifest.ts"],"names":[],"mappings":";AAEA;;;;;;GAMG"}