@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,610 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/manifest/index.ts
31
+ var manifest_exports = {};
32
+ __export(manifest_exports, {
33
+ _ManifestV1: () => _ManifestV1,
34
+ _ManifestV2: () => _ManifestV2,
35
+ _StripeAppManifest: () => _StripeAppManifest
36
+ });
37
+ module.exports = __toCommonJS(manifest_exports);
38
+
39
+ // src/manifest/stripe-app-manifest.ts
40
+ var import_extensibility_tool_utils2 = require("@stripe/extensibility-tool-utils");
41
+
42
+ // src/manifest/manifest-v1.ts
43
+ var import_fs = require("fs");
44
+ function formatCustomObjectEntry(entry) {
45
+ return `${entry.filePath}#${entry.className}`;
46
+ }
47
+ function parseCustomObjectEntry(entryString) {
48
+ const parts = entryString.split("#");
49
+ if (parts.length !== 2) {
50
+ throw new Error(
51
+ `Invalid object entry format: ${entryString}. Expected format: "path/to/file.d.ts#ClassName"`
52
+ );
53
+ }
54
+ const [filePath, className] = parts;
55
+ if (!filePath || !className) {
56
+ throw new Error(
57
+ `Invalid object entry format: ${entryString}. Expected format: "path/to/file.d.ts#ClassName"`
58
+ );
59
+ }
60
+ return { filePath, className };
61
+ }
62
+ var _ManifestV1 = class __ManifestV1 {
63
+ constructor(filePath, data) {
64
+ this.filePath = filePath;
65
+ this.data = data;
66
+ }
67
+ /**
68
+ * Load stripe-app.json from disk
69
+ * @param filePath - Path to stripe-app.json
70
+ * @throws Error if file is invalid or cannot be read
71
+ */
72
+ static load(filePath) {
73
+ if (!(0, import_fs.existsSync)(filePath)) {
74
+ throw new Error(`Manifest file not found: ${filePath}`);
75
+ }
76
+ const content = (0, import_fs.readFileSync)(filePath, "utf-8");
77
+ const data = JSON.parse(content);
78
+ if (!data.id) {
79
+ throw new Error('Manifest must contain "id" field');
80
+ }
81
+ return new __ManifestV1(filePath, data);
82
+ }
83
+ /**
84
+ * Get the app ID from the manifest
85
+ */
86
+ getAppId() {
87
+ return this.data.id;
88
+ }
89
+ /**
90
+ * Get the app name from the manifest
91
+ */
92
+ getAppName() {
93
+ return this.data.name;
94
+ }
95
+ /**
96
+ * Get all custom objects as structured entries
97
+ */
98
+ getCustomObjects() {
99
+ const entries = [];
100
+ if (this.data.exported_custom_objects) {
101
+ for (const entry of this.data.exported_custom_objects) {
102
+ entries.push(parseCustomObjectEntry(entry));
103
+ }
104
+ }
105
+ return entries;
106
+ }
107
+ /**
108
+ * Check if a custom object entry exists in the manifest
109
+ */
110
+ hasCustomObject(entry) {
111
+ const objects = this.getCustomObjects();
112
+ return objects.some(
113
+ (existing) => existing.filePath === entry.filePath && existing.className === entry.className
114
+ );
115
+ }
116
+ /**
117
+ * Add a custom object entry to the manifest
118
+ * Does nothing if entry already exists
119
+ * @returns true if entry was added, false if it already existed
120
+ */
121
+ addCustomObject(entry) {
122
+ if (this.hasCustomObject(entry)) {
123
+ return false;
124
+ }
125
+ const entryString = formatCustomObjectEntry(entry);
126
+ this.data.exported_custom_objects ??= [];
127
+ this.data.exported_custom_objects.push(entryString);
128
+ return true;
129
+ }
130
+ /**
131
+ * Remove a custom object entry from the manifest
132
+ * @returns true if entry was removed, false if it didn't exist
133
+ */
134
+ removeCustomObject(entry) {
135
+ if (!this.data.exported_custom_objects) {
136
+ return false;
137
+ }
138
+ const entryString = formatCustomObjectEntry(entry);
139
+ const originalLength = this.data.exported_custom_objects.length;
140
+ this.data.exported_custom_objects = this.data.exported_custom_objects.filter(
141
+ (e) => e !== entryString
142
+ );
143
+ if (this.data.exported_custom_objects.length === 0) {
144
+ delete this.data.exported_custom_objects;
145
+ }
146
+ return this.data.exported_custom_objects?.length !== originalLength;
147
+ }
148
+ /**
149
+ * Get the raw manifest data (for reading other fields)
150
+ */
151
+ getRawData() {
152
+ return this.data;
153
+ }
154
+ /**
155
+ * Save changes back to disk
156
+ */
157
+ save() {
158
+ (0, import_fs.writeFileSync)(this.filePath, JSON.stringify(this.data, null, 2) + "\n");
159
+ }
160
+ };
161
+
162
+ // src/manifest/manifest-v2.ts
163
+ var import_promises = require("fs/promises");
164
+ var yaml = __toESM(require("yaml"), 1);
165
+ var import_extensibility_tool_utils = require("@stripe/extensibility-tool-utils");
166
+ function isNonEmptyString(value) {
167
+ return typeof value === "string" && value.trim().length > 0;
168
+ }
169
+ function isYamlObject(value) {
170
+ return typeof value === "object" && value !== null && !Array.isArray(value);
171
+ }
172
+ function validateManifestV2Data(data) {
173
+ if (!isNonEmptyString(data.id)) {
174
+ throw new Error('Manifest must contain non-empty "id" field');
175
+ }
176
+ if (!isNonEmptyString(data.name)) {
177
+ throw new Error('Manifest must contain non-empty "name" field');
178
+ }
179
+ if (!isNonEmptyString(data.version)) {
180
+ throw new Error('Manifest must contain non-empty "version" field');
181
+ }
182
+ if ("extensions" in data && !Array.isArray(data.extensions)) {
183
+ throw new Error('Manifest field "extensions" must be an array when provided');
184
+ }
185
+ if ("custom_object_definitions" in data && !isYamlObject(data.custom_object_definitions)) {
186
+ throw new Error(
187
+ 'Manifest field "custom_object_definitions" must be an object with a "definitions" array'
188
+ );
189
+ }
190
+ const coBlock = data.custom_object_definitions;
191
+ const definitions = isYamlObject(coBlock) ? coBlock.definitions : void 0;
192
+ if (!definitions) {
193
+ return;
194
+ }
195
+ if (!Array.isArray(definitions)) {
196
+ throw new Error(
197
+ 'Manifest field "custom_object_definitions.definitions" must be an array'
198
+ );
199
+ }
200
+ for (let i = 0; i < definitions.length; i++) {
201
+ const def = definitions[i];
202
+ const prefix = `custom_object_definitions.definitions[${String(i)}]`;
203
+ if (!isYamlObject(def) || !isNonEmptyString(def.id)) {
204
+ throw new Error(
205
+ `${prefix}: missing or invalid "id" field. Got: ${JSON.stringify(def)}`
206
+ );
207
+ }
208
+ if (!isYamlObject(def.specification)) {
209
+ throw new Error(
210
+ `${prefix}: missing or invalid "specification" field. Expected: { type: "typescript", content: "path/to/file.ts" }. Got: ${JSON.stringify(def)}`
211
+ );
212
+ }
213
+ if (!isNonEmptyString(def.specification.type)) {
214
+ throw new Error(
215
+ `${prefix}: missing or invalid "specification.type" field. Got: ${JSON.stringify(def)}`
216
+ );
217
+ }
218
+ if (!isNonEmptyString(def.specification.content)) {
219
+ throw new Error(
220
+ `${prefix}: missing or invalid "specification.content" field. Got: ${JSON.stringify(def)}`
221
+ );
222
+ }
223
+ }
224
+ }
225
+ var _ManifestV2 = class __ManifestV2 {
226
+ constructor(filePath, data) {
227
+ this.filePath = filePath;
228
+ this.data = data;
229
+ }
230
+ /**
231
+ * Load stripe-app.yaml from disk
232
+ * @param filePath - Path to stripe-app.yaml
233
+ * @throws Error if file is invalid or cannot be read
234
+ */
235
+ static async load(filePath) {
236
+ try {
237
+ const content = await (0, import_promises.readFile)(filePath, "utf-8");
238
+ const parsed = yaml.parse(content);
239
+ if (!isYamlObject(parsed)) {
240
+ throw new Error("Invalid stripe-app.yaml format: root must be an object");
241
+ }
242
+ validateManifestV2Data(parsed);
243
+ const data = parsed;
244
+ data.extensions ??= [];
245
+ return new __ManifestV2(filePath, data);
246
+ } catch (err) {
247
+ if (err instanceof Error) {
248
+ throw new Error(`Error reading stripe-app.yaml: ${err.message}`);
249
+ }
250
+ throw new Error(`Error reading stripe-app.yaml: ${String(err)}`);
251
+ }
252
+ }
253
+ /**
254
+ * Get the app ID from the manifest
255
+ */
256
+ getAppId() {
257
+ return this.data.id;
258
+ }
259
+ /**
260
+ * Get the app name from the manifest
261
+ */
262
+ getAppName() {
263
+ return this.data.name;
264
+ }
265
+ // ============================================================
266
+ // Custom Objects
267
+ // ============================================================
268
+ /**
269
+ * Get all custom object definitions, parsed into internal format.
270
+ * Entries are guaranteed structurally valid by load-time validation.
271
+ */
272
+ getCustomObjects() {
273
+ const definitions = this.data.custom_object_definitions?.definitions;
274
+ if (!definitions || definitions.length === 0) {
275
+ return [];
276
+ }
277
+ return definitions.map((def) => ({
278
+ id: def.id,
279
+ type: def.specification.type,
280
+ path: def.specification.content,
281
+ name: (0, import_extensibility_tool_utils._toPascalCase)(def.id)
282
+ }));
283
+ }
284
+ /**
285
+ * Check if a custom object exists by id
286
+ */
287
+ hasCustomObject(id) {
288
+ const definitions = this.data.custom_object_definitions?.definitions;
289
+ if (!definitions) return false;
290
+ return definitions.some((def) => def.id === id);
291
+ }
292
+ /**
293
+ * Add a custom object definition.
294
+ *
295
+ * Identity is keyed on `id` alone. The export name is derived via
296
+ * `_toPascalCase(id)` at read time, so `id` should be valid snake_case
297
+ * (e.g., "device", "loyalty_card", "http_request").
298
+ *
299
+ * @param id - Object identifier (e.g., "device", "loyalty_card")
300
+ * @param content - Path to the definition file (e.g., "src/device.object.ts")
301
+ * @param type - Specification type, defaults to "typescript"
302
+ * @returns true if added, false if already exists
303
+ */
304
+ addCustomObject(id, content, type = "typescript") {
305
+ if (this.hasCustomObject(id)) {
306
+ return false;
307
+ }
308
+ this.data.custom_object_definitions ??= {};
309
+ this.data.custom_object_definitions.definitions ??= [];
310
+ this.data.custom_object_definitions.definitions.push({
311
+ id,
312
+ specification: { type, content }
313
+ });
314
+ return true;
315
+ }
316
+ /**
317
+ * Remove a custom object definition by id
318
+ * @param id - Object identifier to remove
319
+ * @returns true if removed, false if not found
320
+ */
321
+ removeCustomObject(id) {
322
+ const block = this.data.custom_object_definitions;
323
+ if (!block?.definitions) {
324
+ return false;
325
+ }
326
+ const originalLength = block.definitions.length;
327
+ block.definitions = block.definitions.filter((def) => def.id !== id);
328
+ const newLength = block.definitions.length;
329
+ if (newLength === 0) {
330
+ delete this.data.custom_object_definitions;
331
+ }
332
+ return newLength < originalLength;
333
+ }
334
+ // ============================================================
335
+ // Extensions
336
+ // ============================================================
337
+ /**
338
+ * Add a new extension or update an existing one by ID
339
+ * If an extension with the provided ID exists, it will be replaced entirely
340
+ * @param extension - Extension configuration with all required fields including id
341
+ * @returns The extension ID
342
+ */
343
+ addOrUpdateExtension(extension) {
344
+ const newExtension = {
345
+ id: extension.id,
346
+ name: extension.name,
347
+ interface_id: extension.interface_id,
348
+ version: extension.version,
349
+ ...extension.description !== void 0 && {
350
+ description: extension.description
351
+ },
352
+ ...extension.stripe_version !== void 0 && {
353
+ stripe_version: extension.stripe_version
354
+ },
355
+ ...extension.script_entry_point !== void 0 && {
356
+ script_entry_point: extension.script_entry_point
357
+ },
358
+ ...extension.script !== void 0 && { script: extension.script },
359
+ permissions: extension.permissions,
360
+ methods: extension.methods,
361
+ ...extension.configuration !== void 0 && {
362
+ configuration: extension.configuration
363
+ },
364
+ ...extension.endpoints !== void 0 && {
365
+ endpoints: extension.endpoints
366
+ }
367
+ };
368
+ this.data.extensions ??= [];
369
+ const existingIndex = this.data.extensions.findIndex(
370
+ (ext) => ext.id === extension.id
371
+ );
372
+ if (existingIndex !== -1) {
373
+ this.data.extensions[existingIndex] = newExtension;
374
+ } else {
375
+ this.data.extensions.push(newExtension);
376
+ }
377
+ return extension.id;
378
+ }
379
+ /**
380
+ * Get a read-only view of all extensions
381
+ */
382
+ getExtensions() {
383
+ return this.data.extensions ?? [];
384
+ }
385
+ /**
386
+ * Get the raw manifest data (for reading other fields)
387
+ */
388
+ getRawData() {
389
+ return this.data;
390
+ }
391
+ /**
392
+ * Save changes back to disk
393
+ * @throws Error if file cannot be written
394
+ */
395
+ async save() {
396
+ try {
397
+ const updatedContent = yaml.stringify(this.data);
398
+ await (0, import_promises.writeFile)(this.filePath, updatedContent, "utf-8");
399
+ } catch (err) {
400
+ if (err instanceof Error) {
401
+ throw new Error(`Error writing stripe-app.yaml: ${err.message}`);
402
+ }
403
+ throw new Error(`Error writing stripe-app.yaml: ${String(err)}`);
404
+ }
405
+ }
406
+ };
407
+
408
+ // src/manifest/stripe-app-manifest.ts
409
+ var _StripeAppManifest = class __StripeAppManifest {
410
+ constructor(manifestPath, version, v1, v2) {
411
+ this.manifestPath = manifestPath;
412
+ this.version = version;
413
+ this.v1 = v1;
414
+ this.v2 = v2;
415
+ }
416
+ /**
417
+ * Load a manifest file, automatically detecting the version.
418
+ * @param manifestPath - Path to stripe-app.json or stripe-app.yaml
419
+ * @returns Loaded manifest instance
420
+ */
421
+ static async load(manifestPath) {
422
+ const version = __StripeAppManifest.detectVersion(manifestPath);
423
+ if (version === "v1") {
424
+ const reader = _ManifestV1.load(manifestPath);
425
+ return new __StripeAppManifest(manifestPath, version, reader, null);
426
+ } else {
427
+ const reader = await _ManifestV2.load(manifestPath);
428
+ return new __StripeAppManifest(manifestPath, version, null, reader);
429
+ }
430
+ }
431
+ /**
432
+ * Detect manifest version from file path.
433
+ * TODO: Add content-based detection if needed.
434
+ */
435
+ static detectVersion(manifestPath) {
436
+ const lowerPath = manifestPath.toLowerCase();
437
+ if (lowerPath.endsWith(".yaml") || lowerPath.endsWith(".yml")) {
438
+ return "v2";
439
+ }
440
+ if (lowerPath.endsWith(".json")) {
441
+ return "v1";
442
+ }
443
+ throw new Error(
444
+ `Cannot detect manifest version from path: ${manifestPath}. Expected .json (v1) or .yaml/.yml (v2) extension.`
445
+ );
446
+ }
447
+ /**
448
+ * Get the detected manifest version
449
+ */
450
+ getVersion() {
451
+ return this.version;
452
+ }
453
+ /**
454
+ * Get the manifest file path
455
+ */
456
+ getManifestPath() {
457
+ return this.manifestPath;
458
+ }
459
+ // ============================================================
460
+ // App Metadata (supported by both V1 and V2)
461
+ // ============================================================
462
+ /**
463
+ * Get the app ID from the manifest
464
+ */
465
+ getAppId() {
466
+ if (this.v1) {
467
+ return this.v1.getAppId();
468
+ }
469
+ if (this.v2) {
470
+ return this.v2.getAppId();
471
+ }
472
+ return void 0;
473
+ }
474
+ /**
475
+ * Get the app name from the manifest
476
+ */
477
+ getAppName() {
478
+ if (this.v1) {
479
+ return this.v1.getAppName();
480
+ }
481
+ if (this.v2) {
482
+ return this.v2.getAppName();
483
+ }
484
+ return void 0;
485
+ }
486
+ // ============================================================
487
+ // Custom Objects (supported by both V1 and V2)
488
+ // ============================================================
489
+ /**
490
+ * Get all custom objects from the manifest
491
+ */
492
+ getCustomObjects() {
493
+ if (this.v1) {
494
+ return this.v1.getCustomObjects();
495
+ }
496
+ if (this.v2) {
497
+ return this.v2.getCustomObjects().map((obj) => ({
498
+ filePath: obj.path,
499
+ className: obj.name
500
+ }));
501
+ }
502
+ return [];
503
+ }
504
+ /**
505
+ * Check if a custom object entry exists in the manifest.
506
+ *
507
+ * **V2 note:** Identity is keyed on `_toSnakeCase(className)` alone — `filePath`
508
+ * is not considered. Two entries with the same class name but different file
509
+ * paths are treated as the same object. The `_toSnakeCase` → `_toPascalCase`
510
+ * round-trip is lossless for typical class names but lossy for consecutive
511
+ * uppercase (e.g., `HTTPClient` → `http_client` → `HttpClient`). The manifest
512
+ * `id` field is the source of truth; see `_CustomObjectDefinitionYaml` docs.
513
+ */
514
+ hasCustomObject(entry) {
515
+ if (this.v1) {
516
+ return this.v1.hasCustomObject(entry);
517
+ }
518
+ if (this.v2) {
519
+ return this.v2.hasCustomObject((0, import_extensibility_tool_utils2._toSnakeCase)(entry.className));
520
+ }
521
+ return false;
522
+ }
523
+ /**
524
+ * Add a custom object entry to the manifest.
525
+ *
526
+ * **V2 note:** The manifest `id` is derived as `_toSnakeCase(className)` and
527
+ * `filePath` is stored as the specification `content` path. Identity/dedup
528
+ * is based on `id` alone — see `hasCustomObject` for details.
529
+ *
530
+ * @param entry - The custom object entry to add
531
+ * @returns true if entry was added, false if it already existed
532
+ */
533
+ addCustomObject(entry) {
534
+ if (this.v1) {
535
+ return this.v1.addCustomObject(entry);
536
+ }
537
+ if (this.v2) {
538
+ return this.v2.addCustomObject((0, import_extensibility_tool_utils2._toSnakeCase)(entry.className), entry.filePath);
539
+ }
540
+ return false;
541
+ }
542
+ /**
543
+ * Remove a custom object entry from the manifest.
544
+ *
545
+ * **V2 note:** Removal is keyed on `_toSnakeCase(className)` — `filePath` is
546
+ * not considered. See `hasCustomObject` for identity semantics.
547
+ *
548
+ * @param entry - The custom object entry to remove
549
+ * @returns true if entry was removed, false if it didn't exist
550
+ */
551
+ removeCustomObject(entry) {
552
+ if (this.v1) {
553
+ return this.v1.removeCustomObject(entry);
554
+ }
555
+ if (this.v2) {
556
+ return this.v2.removeCustomObject((0, import_extensibility_tool_utils2._toSnakeCase)(entry.className));
557
+ }
558
+ return false;
559
+ }
560
+ // ============================================================
561
+ // Extensions (V2 only)
562
+ // ============================================================
563
+ /**
564
+ * Get all extensions from the manifest
565
+ * @throws Error if manifest version doesn't support extensions
566
+ */
567
+ getExtensions() {
568
+ if (this.v2) {
569
+ return this.v2.getExtensions();
570
+ }
571
+ throw new Error("Extensions are not supported in V1 manifests (stripe-app.json)");
572
+ }
573
+ /**
574
+ * Add or update an extension in the manifest.
575
+ * If an extension with the same ID exists, it will be replaced.
576
+ *
577
+ * @param config - Full extension configuration
578
+ * @returns The extension ID
579
+ * @throws Error if manifest version doesn't support extensions
580
+ */
581
+ addOrUpdateExtension(config) {
582
+ if (this.v2) {
583
+ return this.v2.addOrUpdateExtension(config);
584
+ }
585
+ throw new Error("Extensions are not supported in V1 manifests (stripe-app.json)");
586
+ }
587
+ // ============================================================
588
+ // Persistence
589
+ // ============================================================
590
+ /**
591
+ * Save changes back to disk
592
+ */
593
+ async save() {
594
+ if (this.v1) {
595
+ this.v1.save();
596
+ return;
597
+ }
598
+ if (this.v2) {
599
+ await this.v2.save();
600
+ return;
601
+ }
602
+ throw new Error("No reader loaded - this should never happen");
603
+ }
604
+ };
605
+ // Annotate the CommonJS export names for ESM import in node:
606
+ 0 && (module.exports = {
607
+ _ManifestV1,
608
+ _ManifestV2,
609
+ _StripeAppManifest
610
+ });
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @deprecated NOT FOR EXTERNAL USE. This subpath is Stripe-internal and will be removed in a future release. External consumers must not depend on it.
3
+ * @internal
4
+ */
5
+ export { _StripeAppManifest, type _ManifestVersion } from './stripe-app-manifest.js';
6
+ export { _ManifestV1, type _ManifestV1Data, type _CustomObjectEntry, } from './manifest-v1.js';
7
+ export { _ManifestV2, type _ManifestV2Data, type _ExtensionConfig, type _ExtensionConfiguration, type _EndpointDefinition, type _EndpointAuth, type _SchemaReference, type _CustomObjectDefinition, type _CustomObjectDefinitionYaml, type _CustomObjectDefinitionsBlock, } from './manifest-v2.js';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/manifest/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,kBAAkB,EAAE,KAAK,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAGrF,OAAO,EACL,WAAW,EACX,KAAK,eAAe,EACpB,KAAK,kBAAkB,GACxB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,WAAW,EACX,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC5B,KAAK,2BAA2B,EAChC,KAAK,6BAA6B,GACnC,MAAM,kBAAkB,CAAC"}