@scenario-labs/sdk 2.2.0 → 2.3.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 (148) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/index.d.mts +1 -0
  3. package/index.d.mts.map +1 -1
  4. package/index.d.ts +1 -0
  5. package/index.d.ts.map +1 -1
  6. package/index.js +3 -1
  7. package/index.js.map +1 -1
  8. package/index.mjs +1 -0
  9. package/index.mjs.map +1 -1
  10. package/lib/auth-refresh.d.mts +52 -0
  11. package/lib/auth-refresh.d.mts.map +1 -0
  12. package/lib/auth-refresh.d.ts +52 -0
  13. package/lib/auth-refresh.d.ts.map +1 -0
  14. package/lib/auth-refresh.js +81 -0
  15. package/lib/auth-refresh.js.map +1 -0
  16. package/lib/auth-refresh.mjs +78 -0
  17. package/lib/auth-refresh.mjs.map +1 -0
  18. package/lib/generate.js +7 -7
  19. package/lib/generate.js.map +1 -1
  20. package/lib/generate.mjs +7 -7
  21. package/lib/generate.mjs.map +1 -1
  22. package/lib/job.d.mts +15 -3
  23. package/lib/job.d.mts.map +1 -1
  24. package/lib/job.d.ts +15 -3
  25. package/lib/job.d.ts.map +1 -1
  26. package/lib/job.js +22 -8
  27. package/lib/job.js.map +1 -1
  28. package/lib/job.mjs +22 -8
  29. package/lib/job.mjs.map +1 -1
  30. package/lib/models.d.mts +8 -2
  31. package/lib/models.d.mts.map +1 -1
  32. package/lib/models.d.ts +8 -2
  33. package/lib/models.d.ts.map +1 -1
  34. package/lib/models.js +13 -5
  35. package/lib/models.js.map +1 -1
  36. package/lib/models.mjs +13 -5
  37. package/lib/models.mjs.map +1 -1
  38. package/lib/scenario.d.mts +28 -13
  39. package/lib/scenario.d.mts.map +1 -1
  40. package/lib/scenario.d.ts +28 -13
  41. package/lib/scenario.d.ts.map +1 -1
  42. package/lib/scenario.js +31 -12
  43. package/lib/scenario.js.map +1 -1
  44. package/lib/scenario.mjs +31 -12
  45. package/lib/scenario.mjs.map +1 -1
  46. package/lib/scope.d.mts +41 -0
  47. package/lib/scope.d.mts.map +1 -0
  48. package/lib/scope.d.ts +41 -0
  49. package/lib/scope.d.ts.map +1 -0
  50. package/lib/scope.js +55 -0
  51. package/lib/scope.js.map +1 -0
  52. package/lib/scope.mjs +49 -0
  53. package/lib/scope.mjs.map +1 -0
  54. package/lib/upload.d.mts +15 -3
  55. package/lib/upload.d.mts.map +1 -1
  56. package/lib/upload.d.ts +15 -3
  57. package/lib/upload.d.ts.map +1 -1
  58. package/lib/upload.js +29 -12
  59. package/lib/upload.js.map +1 -1
  60. package/lib/upload.mjs +29 -12
  61. package/lib/upload.mjs.map +1 -1
  62. package/lib/workflow.d.mts +8 -2
  63. package/lib/workflow.d.mts.map +1 -1
  64. package/lib/workflow.d.ts +8 -2
  65. package/lib/workflow.d.ts.map +1 -1
  66. package/lib/workflow.js +14 -6
  67. package/lib/workflow.js.map +1 -1
  68. package/lib/workflow.mjs +14 -6
  69. package/lib/workflow.mjs.map +1 -1
  70. package/lib/workflow_converter.d.mts +2 -5
  71. package/lib/workflow_converter.d.mts.map +1 -1
  72. package/lib/workflow_converter.d.ts +2 -5
  73. package/lib/workflow_converter.d.ts.map +1 -1
  74. package/lib/workflow_converter.js +38 -3
  75. package/lib/workflow_converter.js.map +1 -1
  76. package/lib/workflow_converter.mjs +38 -3
  77. package/lib/workflow_converter.mjs.map +1 -1
  78. package/lib/workflow_import_validator.d.mts +1 -1
  79. package/lib/workflow_import_validator.d.mts.map +1 -1
  80. package/lib/workflow_import_validator.d.ts +1 -1
  81. package/lib/workflow_import_validator.d.ts.map +1 -1
  82. package/lib/workflow_import_validator.js +1 -0
  83. package/lib/workflow_import_validator.js.map +1 -1
  84. package/lib/workflow_import_validator.mjs +1 -0
  85. package/lib/workflow_import_validator.mjs.map +1 -1
  86. package/package.json +1 -1
  87. package/resources/assets/assets.d.mts +1 -1
  88. package/resources/assets/assets.d.mts.map +1 -1
  89. package/resources/assets/assets.d.ts +1 -1
  90. package/resources/assets/assets.d.ts.map +1 -1
  91. package/resources/generate.d.mts +8 -8
  92. package/resources/generate.d.mts.map +1 -1
  93. package/resources/generate.d.ts +8 -8
  94. package/resources/generate.d.ts.map +1 -1
  95. package/resources/jobs.d.mts +3 -3
  96. package/resources/jobs.d.mts.map +1 -1
  97. package/resources/jobs.d.ts +3 -3
  98. package/resources/jobs.d.ts.map +1 -1
  99. package/resources/models/examples.d.mts +2 -2
  100. package/resources/models/examples.d.mts.map +1 -1
  101. package/resources/models/examples.d.ts +2 -2
  102. package/resources/models/examples.d.ts.map +1 -1
  103. package/resources/models/models.d.mts +126 -7
  104. package/resources/models/models.d.mts.map +1 -1
  105. package/resources/models/models.d.ts +126 -7
  106. package/resources/models/models.d.ts.map +1 -1
  107. package/resources/models/models.js.map +1 -1
  108. package/resources/models/models.mjs.map +1 -1
  109. package/resources/models/train.d.mts +37 -3
  110. package/resources/models/train.d.mts.map +1 -1
  111. package/resources/models/train.d.ts +37 -3
  112. package/resources/models/train.d.ts.map +1 -1
  113. package/resources/usages.d.mts +1 -1
  114. package/resources/usages.d.mts.map +1 -1
  115. package/resources/usages.d.ts +1 -1
  116. package/resources/usages.d.ts.map +1 -1
  117. package/resources/workflows.d.mts +22 -5
  118. package/resources/workflows.d.mts.map +1 -1
  119. package/resources/workflows.d.ts +22 -5
  120. package/resources/workflows.d.ts.map +1 -1
  121. package/resources/workflows.js +4 -1
  122. package/resources/workflows.js.map +1 -1
  123. package/resources/workflows.mjs +4 -1
  124. package/resources/workflows.mjs.map +1 -1
  125. package/src/index.ts +1 -0
  126. package/src/lib/auth-refresh.ts +98 -0
  127. package/src/lib/generate.ts +7 -7
  128. package/src/lib/job.ts +29 -7
  129. package/src/lib/models.ts +14 -4
  130. package/src/lib/scenario.ts +51 -13
  131. package/src/lib/scope.ts +68 -0
  132. package/src/lib/upload.ts +36 -11
  133. package/src/lib/workflow.ts +15 -5
  134. package/src/lib/workflow_converter.ts +47 -6
  135. package/src/lib/workflow_import_validator.ts +3 -1
  136. package/src/resources/assets/assets.ts +1 -1
  137. package/src/resources/generate.ts +8 -8
  138. package/src/resources/jobs.ts +3 -3
  139. package/src/resources/models/examples.ts +2 -2
  140. package/src/resources/models/models.ts +189 -7
  141. package/src/resources/models/train.ts +55 -3
  142. package/src/resources/usages.ts +1 -1
  143. package/src/resources/workflows.ts +24 -5
  144. package/src/version.ts +1 -1
  145. package/version.d.mts +1 -1
  146. package/version.d.ts +1 -1
  147. package/version.js +1 -1
  148. package/version.mjs +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.3.0 (2026-06-04)
4
+
5
+ Full Changelog: [v2.2.1...v2.3.0](https://github.com/scenario-labs/scenario-sdk-typescript/compare/v2.2.1...v2.3.0)
6
+
7
+ ### Features
8
+
9
+ * **api:** api update ([7e95ce3](https://github.com/scenario-labs/scenario-sdk-typescript/commit/7e95ce320a0d6cf09d30fad22403d0dc8d957dfc))
10
+ * **lib:** enhance aspect ratio handling in workflow converter ([702dce9](https://github.com/scenario-labs/scenario-sdk-typescript/commit/702dce9f077b857686104474172cfe2813e690ac))
11
+ * **lib:** enhance aspect ratio handling in workflow converter ([063f84f](https://github.com/scenario-labs/scenario-sdk-typescript/commit/063f84fdef4d3741f70f15a5841990e17277ac26))
12
+ * projectId in params ([#13](https://github.com/scenario-labs/scenario-sdk-typescript/issues/13)) ([350ca01](https://github.com/scenario-labs/scenario-sdk-typescript/commit/350ca0155a2a71828620ca983ed3e64ceba2e2c0))
13
+
14
+ ## 2.2.1 (2026-05-29)
15
+
16
+ Full Changelog: [v2.2.0...v2.2.1](https://github.com/scenario-labs/scenario-sdk-typescript/compare/v2.2.0...v2.2.1)
17
+
18
+ ### Features
19
+
20
+ * **lib:** update aspect ratio handling in workflow converter ([d2cdf0e](https://github.com/scenario-labs/scenario-sdk-typescript/commit/d2cdf0ea7035c50c7853dcdb9aafb9feaf446a44))
21
+
22
+
23
+ ### Bug Fixes
24
+
25
+ * **lib:** workflow converter and validation for approval nodes ([320b6b1](https://github.com/scenario-labs/scenario-sdk-typescript/commit/320b6b128443dc660d9f77465c0e2e6c9e8b2f28))
26
+ * lint ([38f14c1](https://github.com/scenario-labs/scenario-sdk-typescript/commit/38f14c15deeb03da7f0dcb66b792394a70a55f4c))
27
+ * lint ([72465c0](https://github.com/scenario-labs/scenario-sdk-typescript/commit/72465c0064552acd2018d4a7b9ea8a9a529ab27e))
28
+ * lint ([30e035e](https://github.com/scenario-labs/scenario-sdk-typescript/commit/30e035e4ab40f91e7c6b8fad867f3d05857928bc))
29
+ * remove console.log ([578011d](https://github.com/scenario-labs/scenario-sdk-typescript/commit/578011decc6696a793c405ec475408a2d60b2411))
30
+
3
31
  ## 2.2.0 (2026-05-27)
4
32
 
5
33
  Full Changelog: [v2.1.0...v2.2.0](https://github.com/scenario-labs/scenario-sdk-typescript/compare/v2.1.0...v2.2.0)
package/index.d.mts CHANGED
@@ -11,6 +11,7 @@ export { validateWorkflowFlow } from "./lib/workflow_validator.mjs";
11
11
  export { validateEditorInfo, WorkflowImportError, VALID_EDITOR_NODE_TYPES, type WorkflowExportData, type WorkflowEditorNodeType, } from "./lib/workflow_import_validator.mjs";
12
12
  export { EnhancedGenerate } from "./lib/generate.mjs";
13
13
  export { EnhancedModels, EnhancedTrain } from "./lib/models.mjs";
14
+ export { withBearerRefresh, type BearerRefreshOptions } from "./lib/auth-refresh.mjs";
14
15
  export { EnhancedUploads, Upload, type UploadWaitOptions, type WithUpload } from "./lib/upload.mjs";
15
16
  export { EnhancedAssets, Asset, type WithAsset } from "./lib/asset.mjs";
16
17
  export { convertWorkflowEditorToFlow, normalizeAspectRatio, getAspectRatioModelInputNames, getAspectRatioBounds, getDimensionsFromAspectRatio, ASPECT_RATIO_PRESETS, type ConvertWorkflowEditorToFlowParams, type AspectRatioBounds, type AspectRatioModelInputNames, type WorkflowEditorResolutionPreset, type WorkflowEditorNode, type WorkflowEditorEdge, type WorkflowEditorModel, type WorkflowEditorModelInput, type WorkflowEditorHandleInput, type WorkflowEditorHandleOutput, type WorkflowEditorCondition, type WorkflowEditorConditionBlock, type WorkflowEditorFlowItem, type WorkflowEditorFlowInput, type WorkflowEditorFlowInputRef, } from "./lib/workflow_converter.mjs";
package/index.d.mts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,IAAI,OAAO,EAAE,2BAAuB;AAErD,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,EAAE,2BAAuB;AACzD,OAAO,EAAE,UAAU,EAAE,+BAA2B;AAChD,OAAO,EAAE,QAAQ,EAAE,2BAAuB;AAC1C,OAAO,EAAE,KAAK,aAAa,EAAE,qBAAiB;AAC9C,OAAO,EAAE,WAAW,EAAE,8BAA0B;AAChD,OAAO,EACL,aAAa,EACb,QAAQ,EACR,kBAAkB,EAClB,yBAAyB,EACzB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,GACzB,yBAAqB;AACtB,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,KAAK,WAAW,EAAE,KAAK,OAAO,EAAE,sBAAkB;AAC9E,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,2BAAuB;AACnE,OAAO,EAAE,oBAAoB,EAAE,qCAAiC;AAChE,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,EACvB,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,GAC5B,4CAAwC;AACzC,OAAO,EAAE,gBAAgB,EAAE,2BAAuB;AAClD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,yBAAqB;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,KAAK,iBAAiB,EAAE,KAAK,UAAU,EAAE,yBAAqB;AAChG,OAAO,EAAE,cA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ACnB,uBAAuB,EACvB,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,GAC5B,4CAAwC;AACzC,OAAO,EAAE,gBAAgB,EAAE,2BAAuB;AAClD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,yBAAqB;AAC7D,OAAO,EAAE,iBAAiB,EAAE,KAAK,oBAAoB,EAAE,+BAA2B;AAClF,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,KAAK,iBAAiB,EAAE,KAAK,UAAU,EAAE,yBAAqB;AAChG,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,KAAK,SAAS,EAAE,wBAAoB;AACpE,OAAO,EACL,2BAA2B,EAC3B,oBAAoB,EACpB,6BAA6B,EAC7B,oBAAoB,EACpB,4BAA4B,EAC5B,oBAAoB,EACpB,KAAK,iCAAiC,EACtC,KAAK,iBAAiB,EACtB,KAAK,0BAA0B,EAC/B,KAAK,8BAA8B,EACnC,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC9B,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,EAC5B,KAAK,4BAA4B,EACjC,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,0BAA0B,GAChC,qCAAiC"}
package/index.d.ts CHANGED
@@ -11,6 +11,7 @@ export { validateWorkflowFlow } from "./lib/workflow_validator.js";
11
11
  export { validateEditorInfo, WorkflowImportError, VALID_EDITOR_NODE_TYPES, type WorkflowExportData, type WorkflowEditorNodeType, } from "./lib/workflow_import_validator.js";
12
12
  export { EnhancedGenerate } from "./lib/generate.js";
13
13
  export { EnhancedModels, EnhancedTrain } from "./lib/models.js";
14
+ export { withBearerRefresh, type BearerRefreshOptions } from "./lib/auth-refresh.js";
14
15
  export { EnhancedUploads, Upload, type UploadWaitOptions, type WithUpload } from "./lib/upload.js";
15
16
  export { EnhancedAssets, Asset, type WithAsset } from "./lib/asset.js";
16
17
  export { convertWorkflowEditorToFlow, normalizeAspectRatio, getAspectRatioModelInputNames, getAspectRatioBounds, getDimensionsFromAspectRatio, ASPECT_RATIO_PRESETS, type ConvertWorkflowEditorToFlowParams, type AspectRatioBounds, type AspectRatioModelInputNames, type WorkflowEditorResolutionPreset, type WorkflowEditorNode, type WorkflowEditorEdge, type WorkflowEditorModel, type WorkflowEditorModelInput, type WorkflowEditorHandleInput, type WorkflowEditorHandleOutput, type WorkflowEditorCondition, type WorkflowEditorConditionBlock, type WorkflowEditorFlowItem, type WorkflowEditorFlowInput, type WorkflowEditorFlowInputRef, } from "./lib/workflow_converter.js";
package/index.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,IAAI,OAAO,EAAE,0BAAuB;AAErD,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,EAAE,0BAAuB;AACzD,OAAO,EAAE,UAAU,EAAE,8BAA2B;AAChD,OAAO,EAAE,QAAQ,EAAE,0BAAuB;AAC1C,OAAO,EAAE,KAAK,aAAa,EAAE,oBAAiB;AAC9C,OAAO,EAAE,WAAW,EAAE,6BAA0B;AAChD,OAAO,EACL,aAAa,EACb,QAAQ,EACR,kBAAkB,EAClB,yBAAyB,EACzB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,GACzB,wBAAqB;AACtB,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,KAAK,WAAW,EAAE,KAAK,OAAO,EAAE,qBAAkB;AAC9E,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,0BAAuB;AACnE,OAAO,EAAE,oBAAoB,EAAE,oCAAiC;AAChE,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,EACvB,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,GAC5B,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EAAE,YAAY,EAAE,GAAG,EAAE,KAAK,WAAW,EAAE,KAAK,OAAO,EAAE,qBAAkB;AAC9E,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,0BAAuB;AACnE,OAAO,EAAE,oBAAoB,EAAE,oCAAiC;AAChE,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,EACvB,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,GAC5B,2CAAwC;AACzC,OAAO,EAAE,gBAAgB,EAAE,0BAAuB;AAClD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,wBAAqB;AAC7D,OAAO,EAAE,iBAAiB,EAAE,KAAK,oBAAoB,EAAE,8BAA2B;AAClF,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,KAAK,iBAAiB,EAAE,KAAK,UAAU,EAAE,wBAAqB;AAChG,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,KAAK,SAAS,EAAE,uBAAoB;AACpE,OAAO,EACL,2BAA2B,EAC3B,oBAAoB,EACpB,6BAA6B,EAC7B,oBAAoB,EACpB,4BAA4B,EAC5B,oBAAoB,EACpB,KAAK,iCAAiC,EACtC,KAAK,iBAAiB,EACtB,KAAK,0BAA0B,EAC/B,KAAK,8BAA8B,EACnC,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC9B,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,EAC5B,KAAK,4BAA4B,EACjC,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,0BAA0B,GAChC,oCAAiC"}
package/index.js CHANGED
@@ -4,7 +4,7 @@ exports = module.exports = function (...args) {
4
4
  return new exports.default(...args)
5
5
  }
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.ASPECT_RATIO_PRESETS = exports.getDimensionsFromAspectRatio = exports.getAspectRatioBounds = exports.getAspectRatioModelInputNames = exports.normalizeAspectRatio = exports.convertWorkflowEditorToFlow = exports.Asset = exports.EnhancedAssets = exports.Upload = exports.EnhancedUploads = exports.EnhancedTrain = exports.EnhancedModels = exports.EnhancedGenerate = exports.VALID_EDITOR_NODE_TYPES = exports.WorkflowImportError = exports.validateEditorInfo = exports.validateWorkflowFlow = exports.WorkflowEntity = exports.EnhancedWorkflows = exports.Job = exports.EnhancedJobs = exports.UnprocessableEntityError = exports.PermissionDeniedError = exports.InternalServerError = exports.AuthenticationError = exports.BadRequestError = exports.RateLimitError = exports.ConflictError = exports.NotFoundError = exports.APIUserAbortError = exports.APIConnectionTimeoutError = exports.APIConnectionError = exports.APIError = exports.ScenarioError = exports.PagePromise = exports.Scenario = exports.APIPromise = exports.toFile = exports.default = void 0;
7
+ exports.ASPECT_RATIO_PRESETS = exports.getDimensionsFromAspectRatio = exports.getAspectRatioBounds = exports.getAspectRatioModelInputNames = exports.normalizeAspectRatio = exports.convertWorkflowEditorToFlow = exports.Asset = exports.EnhancedAssets = exports.Upload = exports.EnhancedUploads = exports.withBearerRefresh = exports.EnhancedTrain = exports.EnhancedModels = exports.EnhancedGenerate = exports.VALID_EDITOR_NODE_TYPES = exports.WorkflowImportError = exports.validateEditorInfo = exports.validateWorkflowFlow = exports.WorkflowEntity = exports.EnhancedWorkflows = exports.Job = exports.EnhancedJobs = exports.UnprocessableEntityError = exports.PermissionDeniedError = exports.InternalServerError = exports.AuthenticationError = exports.BadRequestError = exports.RateLimitError = exports.ConflictError = exports.NotFoundError = exports.APIUserAbortError = exports.APIConnectionTimeoutError = exports.APIConnectionError = exports.APIError = exports.ScenarioError = exports.PagePromise = exports.Scenario = exports.APIPromise = exports.toFile = exports.default = void 0;
8
8
  var scenario_1 = require("./lib/scenario.js");
9
9
  Object.defineProperty(exports, "default", { enumerable: true, get: function () { return scenario_1.Scenario; } });
10
10
  var uploads_1 = require("./core/uploads.js");
@@ -46,6 +46,8 @@ Object.defineProperty(exports, "EnhancedGenerate", { enumerable: true, get: func
46
46
  var models_1 = require("./lib/models.js");
47
47
  Object.defineProperty(exports, "EnhancedModels", { enumerable: true, get: function () { return models_1.EnhancedModels; } });
48
48
  Object.defineProperty(exports, "EnhancedTrain", { enumerable: true, get: function () { return models_1.EnhancedTrain; } });
49
+ var auth_refresh_1 = require("./lib/auth-refresh.js");
50
+ Object.defineProperty(exports, "withBearerRefresh", { enumerable: true, get: function () { return auth_refresh_1.withBearerRefresh; } });
49
51
  var upload_1 = require("./lib/upload.js");
50
52
  Object.defineProperty(exports, "EnhancedUploads", { enumerable: true, get: function () { return upload_1.EnhancedUploads; } });
51
53
  Object.defineProperty(exports, "Upload", { enumerable: true, get: function () { return upload_1.Upload; } });
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,8CAAqD;AAA5C,mGAAA,QAAQ,OAAW;AAE5B,6CAAyD;AAA/B,iGAAA,MAAM,OAAA;AAChC,qDAAgD;AAAvC,yGAAA,UAAU,OAAA;AACnB,8CAA0C;AAAjC,oGAAA,QAAQ,OAAA;AAEjB,mDAAgD;AAAvC,yGAAA,WAAW,OAAA;AACpB,yCAcsB;AAbpB,sGAAA,aAAa,OAAA;AACb,iGAAA,QAAQ,OAAA;AACR,2GAAA,kBAAkB,OAAA;AAClB,kHAAA,yBAAyB,OAAA;AACzB,0GAAA,iBAAiB,OAAA;AACjB,sGAAA,aAAa,OAAA;AACb,sGAAA,aAAa,OAAA;AACb,uGAAA,cAAc,OAAA;AACd,wGAAA,eAAe,OAAA;AACf,4GAAA,mBAAmB,OAAA;AACnB,4GAAA,mBAAmB,OAAA;AACnB,8GAAA,qBAAqB,OAAA;AACrB,iHAAA,wBAAwB,OAAA;AAE1B,oCAA8E;AAArE,mGAAA,YAAY,OAAA;AAAE,0FAAA,GAAG,OAAA;AAC1B,8CAAmE;AAA1D,6GAAA,iBAAiB,OAAA;AAAE,0GAAA,cAAc,OAAA;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;AAArE,mGAAA,YAAY,OAAA;AAAE,0FAAA,GAAG,OAAA;AAC1B,8CAAmE;AAA1D,6GAAA,iBAAiB,OAAA;AAAE,0GAAA,cAAc,OAAA;AAC1C,kEAAgE;AAAvD,0HAAA,oBAAoB,OAAA;AAC7B,gFAMyC;AALvC,+HAAA,kBAAkB,OAAA;AAClB,gIAAA,mBAAmB,OAAA;AACnB,oIAAA,uBAAuB,OAAA;AAIzB,8CAAkD;AAAzC,4GAAA,gBAAgB,OAAA;AACzB,0CAA6D;AAApD,wGAAA,cAAc,OAAA;AAAE,uGAAA,aAAa,OAAA;AACtC,sDAAkF;AAAzE,iHAAA,iBAAiB,OAAA;AAC1B,0CAAgG;AAAvF,yGAAA,eAAe,OAAA;AAAE,gGAAA,MAAM,OAAA;AAChC,wCAAoE;AAA3D,uGAAA,cAAc,OAAA;AAAE,8FAAA,KAAK,OAAA;AAC9B,kEAsBkC;AArBhC,iIAAA,2BAA2B,OAAA;AAC3B,0HAAA,oBAAoB,OAAA;AACpB,mIAAA,6BAA6B,OAAA;AAC7B,0HAAA,oBAAoB,OAAA;AACpB,kIAAA,4BAA4B,OAAA;AAC5B,0HAAA,oBAAoB,OAAA"}
package/index.mjs CHANGED
@@ -11,6 +11,7 @@ export { validateWorkflowFlow } from "./lib/workflow_validator.mjs";
11
11
  export { validateEditorInfo, WorkflowImportError, VALID_EDITOR_NODE_TYPES, } from "./lib/workflow_import_validator.mjs";
12
12
  export { EnhancedGenerate } from "./lib/generate.mjs";
13
13
  export { EnhancedModels, EnhancedTrain } from "./lib/models.mjs";
14
+ export { withBearerRefresh } from "./lib/auth-refresh.mjs";
14
15
  export { EnhancedUploads, Upload } from "./lib/upload.mjs";
15
16
  export { EnhancedAssets, Asset } from "./lib/asset.mjs";
16
17
  export { convertWorkflowEditorToFlow, normalizeAspectRatio, getAspectRatioModelInputNames, getAspectRatioBounds, getDimensionsFromAspectRatio, ASPECT_RATIO_PRESETS, } from "./lib/workflow_converter.mjs";
package/index.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,OAAO,EAAE,QAAQ,IAAI,OAAO,EAAE,2BAAuB;AAErD,OAAO,EAAmB,MAAM,EAAE,2BAAuB;AACzD,OAAO,EAAE,UAAU,EAAE,+BAA2B;AAChD,OAAO,EAAE,QAAQ,EAAE,2BAAuB;AAE1C,OAAO,EAAE,WAAW,EAAE,8BAA0B;AAChD,OAAO,EACL,aAAa,EACb,QAAQ,EACR,kBAAkB,EAClB,yBAAyB,EACzB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,GACzB,yBAAqB;AACtB,OAAO,EAAE,YAAY,EAAE,GAAG,EAAkC,sBAAkB;AAC9E,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,2BAAuB;AACnE,OAAO,EAAE,oBAAoB,EAAE,qCAAiC;AAChE,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,GAGxB,4CAAwC;AACzC,OAAO,EAAE,gBAAgB,EAAE,2BAAuB;AAClD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,yBAAqB;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,EAA2C,yBAAqB;AAChG,OAAO,EAAE,cAAc,EAAE,KAAK,EAAkB,wBAAoB;AACpE,OAAO,EACL,2BAA2B,EAC3B,oBAAoB,EACpB,6BAA6B,EAC7B,oBAAoB,EACpB,4BAA4B,EAC5B,oBAAoB,GAgBrB,qCAAiC"}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,OAAO,EAAE,QAAQ,IAAI,OAAO,EAAE,2BAAuB;AAErD,OAAO,EAAmB,MAAM,EAAE,2BAAuB;AACzD,OAAO,EAAE,UAAU,EAAE,+BAA2B;AAChD,OAAO,EAAE,QAAQ,EAAE,2BAAuB;AAE1C,OAAO,EAAE,WAAW,EAAE,8BAA0B;AAChD,OAAO,EACL,aAAa,EACb,QAAQ,EACR,kBAAkB,EAClB,yBAAyB,EACzB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,GACzB,yBAAqB;AACtB,OAAO,EAAE,YAAY,EAAE,GAAG,EAAkC,sBAAkB;AAC9E,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,2BAAuB;AACnE,OAAO,EAAE,oBAAoB,EAAE,qCAAiC;AAChE,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,GAGxB,4CAAwC;AACzC,OAAO,EAAE,gBAAgB,EAAE,2BAAuB;AAClD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,yBAAqB;AAC7D,OAAO,EAAE,iBAAiB,EAA6B,+BAA2B;AAClF,OAAO,EAAE,eAAe,EAAE,MAAM,EAA2C,yBAAqB;AAChG,OAAO,EAAE,cAAc,EAAE,KAAK,EAAkB,wBAAoB;AACpE,OAAO,EACL,2BAA2B,EAC3B,oBAAoB,EACpB,6BAA6B,EAC7B,oBAAoB,EACpB,4BAA4B,EAC5B,oBAAoB,GAgBrB,qCAAiC"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Wrap `fetch` so that AWS API Gateway authorizer rejections (i.e. expired
3
+ * bearer JWTs) automatically trigger a refresh + retry.
4
+ *
5
+ * Use case: bearer (JWT) auth only. Clerk session tokens default to ~60s
6
+ * validity, so any single SDK call that outlives that window — typically a
7
+ * `.wait()` poll on a long job, or a slow `uploadFile()` — risks getting a
8
+ * 403 mid-flight even though the user is still authenticated. This wrapper
9
+ * intercepts those 403s, calls a caller-provided refresh callback to mint a
10
+ * fresh JWT, and retries the same request transparently.
11
+ *
12
+ * Not applicable to API-key auth: API keys are long-lived credentials and
13
+ * don't expire mid-session.
14
+ *
15
+ * Detection: AWS API Gateway sets `x-amzn-errortype: AccessDeniedException`
16
+ * on authorizer rejections. Real downstream permission denials return 403
17
+ * *without* that header — those are propagated unchanged so we don't refresh
18
+ * pointlessly on a genuine "you don't have access" response.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * import { Scenario, withBearerRefresh } from '@scenario-labs/sdk';
23
+ *
24
+ * const client = new Scenario({
25
+ * bearerAuth: initialJwt,
26
+ * fetch: withBearerRefresh(async () => {
27
+ * // app-specific: re-mint a JWT from Clerk, your IdP, etc.
28
+ * return await mintFreshJwt();
29
+ * }),
30
+ * });
31
+ *
32
+ * // Long-running poll — JWT can expire mid-flight, wrapper handles it:
33
+ * const job = await client.workflows.run(wfId, { body }).then(r => r.job);
34
+ * const completed = await job.wait({ timeoutMs: 600_000 });
35
+ * ```
36
+ */
37
+ export declare function withBearerRefresh(refresh: () => Promise<string | null>, options?: BearerRefreshOptions): typeof fetch;
38
+ export interface BearerRefreshOptions {
39
+ /**
40
+ * Maximum number of refresh attempts per wrapper instance. After this many
41
+ * refreshes, subsequent authorizer 403s are propagated unchanged.
42
+ * @default 2
43
+ */
44
+ maxRefreshes?: number;
45
+ /**
46
+ * Underlying fetch to wrap. Use this to compose with other fetch wrappers
47
+ * (logging, retries, etc.) or to inject a mock in tests.
48
+ * @default globalThis.fetch
49
+ */
50
+ fetch?: typeof fetch;
51
+ }
52
+ //# sourceMappingURL=auth-refresh.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-refresh.d.mts","sourceRoot":"","sources":["../src/lib/auth-refresh.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,EACrC,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,KAAK,CA2Cd;AAED,MAAM,WAAW,oBAAoB;IACnC;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACtB"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Wrap `fetch` so that AWS API Gateway authorizer rejections (i.e. expired
3
+ * bearer JWTs) automatically trigger a refresh + retry.
4
+ *
5
+ * Use case: bearer (JWT) auth only. Clerk session tokens default to ~60s
6
+ * validity, so any single SDK call that outlives that window — typically a
7
+ * `.wait()` poll on a long job, or a slow `uploadFile()` — risks getting a
8
+ * 403 mid-flight even though the user is still authenticated. This wrapper
9
+ * intercepts those 403s, calls a caller-provided refresh callback to mint a
10
+ * fresh JWT, and retries the same request transparently.
11
+ *
12
+ * Not applicable to API-key auth: API keys are long-lived credentials and
13
+ * don't expire mid-session.
14
+ *
15
+ * Detection: AWS API Gateway sets `x-amzn-errortype: AccessDeniedException`
16
+ * on authorizer rejections. Real downstream permission denials return 403
17
+ * *without* that header — those are propagated unchanged so we don't refresh
18
+ * pointlessly on a genuine "you don't have access" response.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * import { Scenario, withBearerRefresh } from '@scenario-labs/sdk';
23
+ *
24
+ * const client = new Scenario({
25
+ * bearerAuth: initialJwt,
26
+ * fetch: withBearerRefresh(async () => {
27
+ * // app-specific: re-mint a JWT from Clerk, your IdP, etc.
28
+ * return await mintFreshJwt();
29
+ * }),
30
+ * });
31
+ *
32
+ * // Long-running poll — JWT can expire mid-flight, wrapper handles it:
33
+ * const job = await client.workflows.run(wfId, { body }).then(r => r.job);
34
+ * const completed = await job.wait({ timeoutMs: 600_000 });
35
+ * ```
36
+ */
37
+ export declare function withBearerRefresh(refresh: () => Promise<string | null>, options?: BearerRefreshOptions): typeof fetch;
38
+ export interface BearerRefreshOptions {
39
+ /**
40
+ * Maximum number of refresh attempts per wrapper instance. After this many
41
+ * refreshes, subsequent authorizer 403s are propagated unchanged.
42
+ * @default 2
43
+ */
44
+ maxRefreshes?: number;
45
+ /**
46
+ * Underlying fetch to wrap. Use this to compose with other fetch wrappers
47
+ * (logging, retries, etc.) or to inject a mock in tests.
48
+ * @default globalThis.fetch
49
+ */
50
+ fetch?: typeof fetch;
51
+ }
52
+ //# sourceMappingURL=auth-refresh.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-refresh.d.ts","sourceRoot":"","sources":["../src/lib/auth-refresh.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,EACrC,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,KAAK,CA2Cd;AAED,MAAM,WAAW,oBAAoB;IACnC;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACtB"}
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withBearerRefresh = withBearerRefresh;
4
+ /**
5
+ * Wrap `fetch` so that AWS API Gateway authorizer rejections (i.e. expired
6
+ * bearer JWTs) automatically trigger a refresh + retry.
7
+ *
8
+ * Use case: bearer (JWT) auth only. Clerk session tokens default to ~60s
9
+ * validity, so any single SDK call that outlives that window — typically a
10
+ * `.wait()` poll on a long job, or a slow `uploadFile()` — risks getting a
11
+ * 403 mid-flight even though the user is still authenticated. This wrapper
12
+ * intercepts those 403s, calls a caller-provided refresh callback to mint a
13
+ * fresh JWT, and retries the same request transparently.
14
+ *
15
+ * Not applicable to API-key auth: API keys are long-lived credentials and
16
+ * don't expire mid-session.
17
+ *
18
+ * Detection: AWS API Gateway sets `x-amzn-errortype: AccessDeniedException`
19
+ * on authorizer rejections. Real downstream permission denials return 403
20
+ * *without* that header — those are propagated unchanged so we don't refresh
21
+ * pointlessly on a genuine "you don't have access" response.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * import { Scenario, withBearerRefresh } from '@scenario-labs/sdk';
26
+ *
27
+ * const client = new Scenario({
28
+ * bearerAuth: initialJwt,
29
+ * fetch: withBearerRefresh(async () => {
30
+ * // app-specific: re-mint a JWT from Clerk, your IdP, etc.
31
+ * return await mintFreshJwt();
32
+ * }),
33
+ * });
34
+ *
35
+ * // Long-running poll — JWT can expire mid-flight, wrapper handles it:
36
+ * const job = await client.workflows.run(wfId, { body }).then(r => r.job);
37
+ * const completed = await job.wait({ timeoutMs: 600_000 });
38
+ * ```
39
+ */
40
+ function withBearerRefresh(refresh, options) {
41
+ const inner = options?.fetch ?? globalThis.fetch;
42
+ const maxRefreshes = options?.maxRefreshes ?? 2;
43
+ let refreshCount = 0;
44
+ // Concurrent requests that all hit a gateway 403 must share a single
45
+ // refresh — otherwise each call mints its own JWT, wastes the refresh
46
+ // budget, and risks token-version races. We coalesce them onto one
47
+ // in-flight promise (single-flight).
48
+ let inflightRefresh = null;
49
+ return async (input, init) => {
50
+ const response = await inner(input, init);
51
+ const isAuthorizerReject = response.status === 403 && response.headers.get('x-amzn-errortype') === 'AccessDeniedException';
52
+ if (!isAuthorizerReject)
53
+ return response;
54
+ // Budget only blocks NEW refreshes — followers awaiting an in-flight
55
+ // refresh aren't paying for it, so let them through.
56
+ if (refreshCount >= maxRefreshes && inflightRefresh === null)
57
+ return response;
58
+ if (inflightRefresh === null) {
59
+ // Leader for this round: charge the budget now (not on result) so
60
+ // followers awaiting the same promise don't each increment.
61
+ refreshCount += 1;
62
+ inflightRefresh = refresh().finally(() => {
63
+ inflightRefresh = null;
64
+ });
65
+ }
66
+ const freshJwt = await inflightRefresh;
67
+ if (!freshJwt) {
68
+ // Refresh failed — propagate the original 403 with its body intact so
69
+ // the SDK / caller can still read the error message. Draining here
70
+ // would leave them with an empty/closed stream.
71
+ return response;
72
+ }
73
+ // Refresh succeeded; we're about to retry. Drain the rejected response's
74
+ // body so we don't leak the underlying socket.
75
+ response.body?.cancel().catch(() => undefined);
76
+ const newHeaders = new Headers(init?.headers);
77
+ newHeaders.set('Authorization', `Bearer ${freshJwt}`);
78
+ return inner(input, { ...init, headers: newHeaders });
79
+ };
80
+ }
81
+ //# sourceMappingURL=auth-refresh.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-refresh.js","sourceRoot":"","sources":["../src/lib/auth-refresh.ts"],"names":[],"mappings":";;AAoCA,8CA8CC;AAlFD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,SAAgB,iBAAiB,CAC/B,OAAqC,EACrC,OAA8B;IAE9B,MAAM,KAAK,GAAG,OAAO,EAAE,KAAK,IAAI,UAAU,CAAC,KAAK,CAAC;IACjD,MAAM,YAAY,GAAG,OAAO,EAAE,YAAY,IAAI,CAAC,CAAC;IAChD,IAAI,YAAY,GAAG,CAAC,CAAC;IACrB,qEAAqE;IACrE,sEAAsE;IACtE,mEAAmE;IACnE,qCAAqC;IACrC,IAAI,eAAe,GAAkC,IAAI,CAAC;IAE1D,OAAO,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QAC3B,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAC1C,MAAM,kBAAkB,GACtB,QAAQ,CAAC,MAAM,KAAK,GAAG,IAAI,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,KAAK,uBAAuB,CAAC;QAClG,IAAI,CAAC,kBAAkB;YAAE,OAAO,QAAQ,CAAC;QACzC,qEAAqE;QACrE,qDAAqD;QACrD,IAAI,YAAY,IAAI,YAAY,IAAI,eAAe,KAAK,IAAI;YAAE,OAAO,QAAQ,CAAC;QAE9E,IAAI,eAAe,KAAK,IAAI,EAAE,CAAC;YAC7B,kEAAkE;YAClE,4DAA4D;YAC5D,YAAY,IAAI,CAAC,CAAC;YAClB,eAAe,GAAG,OAAO,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE;gBACvC,eAAe,GAAG,IAAI,CAAC;YACzB,CAAC,CAAC,CAAC;QACL,CAAC;QACD,MAAM,QAAQ,GAAG,MAAM,eAAe,CAAC;QACvC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,sEAAsE;YACtE,mEAAmE;YACnE,gDAAgD;YAChD,OAAO,QAAQ,CAAC;QAClB,CAAC;QAED,yEAAyE;QACzE,+CAA+C;QAC/C,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAE/C,MAAM,UAAU,GAAG,IAAI,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC9C,UAAU,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,QAAQ,EAAE,CAAC,CAAC;QACtD,OAAO,KAAK,CAAC,KAAK,EAAE,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC;IACxD,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Wrap `fetch` so that AWS API Gateway authorizer rejections (i.e. expired
3
+ * bearer JWTs) automatically trigger a refresh + retry.
4
+ *
5
+ * Use case: bearer (JWT) auth only. Clerk session tokens default to ~60s
6
+ * validity, so any single SDK call that outlives that window — typically a
7
+ * `.wait()` poll on a long job, or a slow `uploadFile()` — risks getting a
8
+ * 403 mid-flight even though the user is still authenticated. This wrapper
9
+ * intercepts those 403s, calls a caller-provided refresh callback to mint a
10
+ * fresh JWT, and retries the same request transparently.
11
+ *
12
+ * Not applicable to API-key auth: API keys are long-lived credentials and
13
+ * don't expire mid-session.
14
+ *
15
+ * Detection: AWS API Gateway sets `x-amzn-errortype: AccessDeniedException`
16
+ * on authorizer rejections. Real downstream permission denials return 403
17
+ * *without* that header — those are propagated unchanged so we don't refresh
18
+ * pointlessly on a genuine "you don't have access" response.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * import { Scenario, withBearerRefresh } from '@scenario-labs/sdk';
23
+ *
24
+ * const client = new Scenario({
25
+ * bearerAuth: initialJwt,
26
+ * fetch: withBearerRefresh(async () => {
27
+ * // app-specific: re-mint a JWT from Clerk, your IdP, etc.
28
+ * return await mintFreshJwt();
29
+ * }),
30
+ * });
31
+ *
32
+ * // Long-running poll — JWT can expire mid-flight, wrapper handles it:
33
+ * const job = await client.workflows.run(wfId, { body }).then(r => r.job);
34
+ * const completed = await job.wait({ timeoutMs: 600_000 });
35
+ * ```
36
+ */
37
+ export function withBearerRefresh(refresh, options) {
38
+ const inner = options?.fetch ?? globalThis.fetch;
39
+ const maxRefreshes = options?.maxRefreshes ?? 2;
40
+ let refreshCount = 0;
41
+ // Concurrent requests that all hit a gateway 403 must share a single
42
+ // refresh — otherwise each call mints its own JWT, wastes the refresh
43
+ // budget, and risks token-version races. We coalesce them onto one
44
+ // in-flight promise (single-flight).
45
+ let inflightRefresh = null;
46
+ return async (input, init) => {
47
+ const response = await inner(input, init);
48
+ const isAuthorizerReject = response.status === 403 && response.headers.get('x-amzn-errortype') === 'AccessDeniedException';
49
+ if (!isAuthorizerReject)
50
+ return response;
51
+ // Budget only blocks NEW refreshes — followers awaiting an in-flight
52
+ // refresh aren't paying for it, so let them through.
53
+ if (refreshCount >= maxRefreshes && inflightRefresh === null)
54
+ return response;
55
+ if (inflightRefresh === null) {
56
+ // Leader for this round: charge the budget now (not on result) so
57
+ // followers awaiting the same promise don't each increment.
58
+ refreshCount += 1;
59
+ inflightRefresh = refresh().finally(() => {
60
+ inflightRefresh = null;
61
+ });
62
+ }
63
+ const freshJwt = await inflightRefresh;
64
+ if (!freshJwt) {
65
+ // Refresh failed — propagate the original 403 with its body intact so
66
+ // the SDK / caller can still read the error message. Draining here
67
+ // would leave them with an empty/closed stream.
68
+ return response;
69
+ }
70
+ // Refresh succeeded; we're about to retry. Drain the rejected response's
71
+ // body so we don't leak the underlying socket.
72
+ response.body?.cancel().catch(() => undefined);
73
+ const newHeaders = new Headers(init?.headers);
74
+ newHeaders.set('Authorization', `Bearer ${freshJwt}`);
75
+ return inner(input, { ...init, headers: newHeaders });
76
+ };
77
+ }
78
+ //# sourceMappingURL=auth-refresh.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-refresh.mjs","sourceRoot":"","sources":["../src/lib/auth-refresh.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,UAAU,iBAAiB,CAC/B,OAAqC,EACrC,OAA8B;IAE9B,MAAM,KAAK,GAAG,OAAO,EAAE,KAAK,IAAI,UAAU,CAAC,KAAK,CAAC;IACjD,MAAM,YAAY,GAAG,OAAO,EAAE,YAAY,IAAI,CAAC,CAAC;IAChD,IAAI,YAAY,GAAG,CAAC,CAAC;IACrB,qEAAqE;IACrE,sEAAsE;IACtE,mEAAmE;IACnE,qCAAqC;IACrC,IAAI,eAAe,GAAkC,IAAI,CAAC;IAE1D,OAAO,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QAC3B,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAC1C,MAAM,kBAAkB,GACtB,QAAQ,CAAC,MAAM,KAAK,GAAG,IAAI,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,KAAK,uBAAuB,CAAC;QAClG,IAAI,CAAC,kBAAkB;YAAE,OAAO,QAAQ,CAAC;QACzC,qEAAqE;QACrE,qDAAqD;QACrD,IAAI,YAAY,IAAI,YAAY,IAAI,eAAe,KAAK,IAAI;YAAE,OAAO,QAAQ,CAAC;QAE9E,IAAI,eAAe,KAAK,IAAI,EAAE,CAAC;YAC7B,kEAAkE;YAClE,4DAA4D;YAC5D,YAAY,IAAI,CAAC,CAAC;YAClB,eAAe,GAAG,OAAO,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE;gBACvC,eAAe,GAAG,IAAI,CAAC;YACzB,CAAC,CAAC,CAAC;QACL,CAAC;QACD,MAAM,QAAQ,GAAG,MAAM,eAAe,CAAC;QACvC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,sEAAsE;YACtE,mEAAmE;YACnE,gDAAgD;YAChD,OAAO,QAAQ,CAAC;QAClB,CAAC;QAED,yEAAyE;QACzE,+CAA+C;QAC/C,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAE/C,MAAM,UAAU,GAAG,IAAI,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC9C,UAAU,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,QAAQ,EAAE,CAAC,CAAC;QACtD,OAAO,KAAK,CAAC,KAAK,EAAE,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC;IACxD,CAAC,CAAC;AACJ,CAAC"}
package/lib/generate.js CHANGED
@@ -10,25 +10,25 @@ const job_1 = require("./job.js");
10
10
  */
11
11
  class EnhancedGenerate extends generate_1.Generate {
12
12
  caption(params, options) {
13
- return (0, job_1.enhanceJob)(this._client, super.caption(params, options));
13
+ return (0, job_1.enhanceJob)(this._client, super.caption(params, options), options);
14
14
  }
15
15
  describeStyle(params, options) {
16
- return (0, job_1.enhanceJob)(this._client, super.describeStyle(params, options));
16
+ return (0, job_1.enhanceJob)(this._client, super.describeStyle(params, options), options);
17
17
  }
18
18
  detect(params, options) {
19
- return (0, job_1.enhanceJob)(this._client, super.detect(params, options));
19
+ return (0, job_1.enhanceJob)(this._client, super.detect(params, options), options);
20
20
  }
21
21
  embed(params, options) {
22
- return (0, job_1.enhanceJob)(this._client, super.embed(params, options));
22
+ return (0, job_1.enhanceJob)(this._client, super.embed(params, options), options);
23
23
  }
24
24
  patch(params, options) {
25
- return (0, job_1.enhanceJob)(this._client, super.patch(params, options));
25
+ return (0, job_1.enhanceJob)(this._client, super.patch(params, options), options);
26
26
  }
27
27
  runModel(modelID, params, options) {
28
- return (0, job_1.enhanceJob)(this._client, super.runModel(modelID, params, options));
28
+ return (0, job_1.enhanceJob)(this._client, super.runModel(modelID, params, options), options);
29
29
  }
30
30
  translate(params, options) {
31
- return (0, job_1.enhanceJob)(this._client, super.translate(params, options));
31
+ return (0, job_1.enhanceJob)(this._client, super.translate(params, options), options);
32
32
  }
33
33
  }
34
34
  exports.EnhancedGenerate = EnhancedGenerate;
@@ -1 +1 @@
1
- {"version":3,"file":"generate.js","sourceRoot":"","sources":["../src/lib/generate.ts"],"names":[],"mappings":";;;AAEA,uDAgB+B;AAC/B,kCAAiD;AAEjD;;;;GAIG;AACH,MAAa,gBAAiB,SAAQ,mBAAQ;IACnC,OAAO,CACd,MAA6B,EAC7B,OAAwB;QAExB,OAAO,IAAA,gBAAU,EAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAClE,CAAC;IAEQ,aAAa,CACpB,MAAmC,EACnC,OAAwB;QAExB,OAAO,IAAA,gBAAU,EAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACxE,CAAC;IAEQ,MAAM,CACb,MAA4B,EAC5B,OAAwB;QAExB,OAAO,IAAA,gBAAU,EAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACjE,CAAC;IAEQ,KAAK,CACZ,MAA2B,EAC3B,OAAwB;QAExB,OAAO,IAAA,gBAAU,EAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAChE,CAAC;IAEQ,KAAK,CACZ,MAA2B,EAC3B,OAAwB;QAExB,OAAO,IAAA,gBAAU,EAAC,IAAI,CAAC,OAAO,EA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AAC,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;IACzE,CAAC;IAEQ,KAAK,CACZ,MAA2B,EAC3B,OAAwB;QAExB,OAAO,IAAA,gBAAU,EAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;IACzE,CAAC;IAEQ,QAAQ,CACf,OAAe,EACf,MAA8B,EAC9B,OAAwB;QAExB,OAAO,IAAA,gBAAU,EAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;IACrF,CAAC;IAEQ,SAAS,CAChB,MAA+B,EAC/B,OAAwB;QAExB,OAAO,IAAA,gBAAU,EAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;IAC7E,CAAC;CACF;AAlDD,4CAkDC"}
package/lib/generate.mjs CHANGED
@@ -7,25 +7,25 @@ import { enhanceJob } from "./job.mjs";
7
7
  */
8
8
  export class EnhancedGenerate extends Generate {
9
9
  caption(params, options) {
10
- return enhanceJob(this._client, super.caption(params, options));
10
+ return enhanceJob(this._client, super.caption(params, options), options);
11
11
  }
12
12
  describeStyle(params, options) {
13
- return enhanceJob(this._client, super.describeStyle(params, options));
13
+ return enhanceJob(this._client, super.describeStyle(params, options), options);
14
14
  }
15
15
  detect(params, options) {
16
- return enhanceJob(this._client, super.detect(params, options));
16
+ return enhanceJob(this._client, super.detect(params, options), options);
17
17
  }
18
18
  embed(params, options) {
19
- return enhanceJob(this._client, super.embed(params, options));
19
+ return enhanceJob(this._client, super.embed(params, options), options);
20
20
  }
21
21
  patch(params, options) {
22
- return enhanceJob(this._client, super.patch(params, options));
22
+ return enhanceJob(this._client, super.patch(params, options), options);
23
23
  }
24
24
  runModel(modelID, params, options) {
25
- return enhanceJob(this._client, super.runModel(modelID, params, options));
25
+ return enhanceJob(this._client, super.runModel(modelID, params, options), options);
26
26
  }
27
27
  translate(params, options) {
28
- return enhanceJob(this._client, super.translate(params, options));
28
+ return enhanceJob(this._client, super.translate(params, options), options);
29
29
  }
30
30
  }
31
31
  //# sourceMappingURL=generate.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate.mjs","sourceRoot":"","sources":["../src/lib/generate.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,QAAQ,GAeT,kCAA8B;AAC/B,OAAO,EAAgB,UAAU,EAAE,kBAAc;AAEjD;;;;GAIG;AACH,MAAM,OAAO,gBAAiB,SAAQ,QAAQ;IACnC,OAAO,CACd,MAA6B,EAC7B,OAAwB;QAExB,OAAO,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAClE,CAAC;IAEQ,aAAa,CACpB,MAAmC,EACnC,OAAwB;QAExB,OAAO,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACxE,CAAC;IAEQ,MAAM,CACb,MAA4B,EAC5B,OAAwB;QAExB,OAAO,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACjE,CAAC;IAEQ,KAAK,CACZ,MAA2B,EAC3B,OAAwB;QAExB,OAAO,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAChE,CAAC;IAEQ,KAAK,CACZ,MAA2B,EAC3B,OAAwB;QAExB,OAAO,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,O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AAE,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;IACzE,CAAC;IAEQ,KAAK,CACZ,MAA2B,EAC3B,OAAwB;QAExB,OAAO,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;IACzE,CAAC;IAEQ,QAAQ,CACf,OAAe,EACf,MAA8B,EAC9B,OAAwB;QAExB,OAAO,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;IACrF,CAAC;IAEQ,SAAS,CAChB,MAA+B,EAC/B,OAAwB;QAExB,OAAO,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;IAC7E,CAAC;CACF"}
package/lib/job.d.mts CHANGED
@@ -2,15 +2,24 @@ import type { Scenario } from "../client.mjs";
2
2
  import type { APIPromise } from "../core/api-promise.mjs";
3
3
  import type { RequestOptions } from "../internal/request-options.mjs";
4
4
  import { Jobs, type JobRetrieveResponse, type JobTriggerActionParams, type JobTriggerActionResponse } from "../resources/jobs.mjs";
5
+ import { type Scope } from "./scope.mjs";
5
6
  export interface WaitOptions {
6
7
  /** Polling interval in milliseconds. Default: 3000 */
7
8
  intervalMs?: number;
8
9
  /** Maximum wait time in milliseconds. Default: 120000 */
9
10
  timeoutMs?: number;
11
+ /**
12
+ * Override the project scope used for the polling requests. Defaults to
13
+ * the scope captured on the job (per-call override on the originating
14
+ * call, else the client's default project).
15
+ */
16
+ projectId?: string;
10
17
  }
11
18
  /** Job methods added on top of the original job fields. */
12
19
  export declare class JobMethods {
13
20
  /** @internal */ readonly _client: Scenario;
21
+ /** @internal scope captured from the originating call — replayed on every `.wait()` poll. */
22
+ readonly _scope?: Scope;
14
23
  /**
15
24
  * Poll until the job reaches a terminal status (success, failure, or canceled).
16
25
  *
@@ -22,8 +31,8 @@ export declare class JobMethods {
22
31
  * ```
23
32
  */
24
33
  wait(this: Job, options?: WaitOptions): Promise<Job>;
25
- /** @internal Create a Job from raw job data. */
26
- static from(client: Scenario, data: JobRetrieveResponse['job']): Job;
34
+ /** @internal Create a Job from raw job data, optionally remembering the originating scope. */
35
+ static from(client: Scenario, data: JobRetrieveResponse['job'], scope?: Scope): Job;
27
36
  }
28
37
  /** A job with all original fields plus `.wait()`. */
29
38
  export type Job = JobRetrieveResponse.Job & JobMethods;
@@ -39,13 +48,16 @@ export type WithJob<T extends {
39
48
  };
40
49
  /**
41
50
  * @internal Wrap `_thenUnwrap` to replace `response.job` with an enhanced Job.
51
+ * Captures the effective scope (per-call override or client default) so
52
+ * `.wait()` can replay it on every poll — keeping follow-up calls in sync
53
+ * with the project the job was originally created in.
42
54
  */
43
55
  export declare function enhanceJob<T extends {
44
56
  job: {
45
57
  jobId: string;
46
58
  status: string;
47
59
  };
48
- }>(client: Scenario, promise: APIPromise<T>): APIPromise<WithJob<T>>;
60
+ }>(client: Scenario, promise: APIPromise<T>, options?: RequestOptions): APIPromise<WithJob<T>>;
49
61
  /**
50
62
  * Enhanced Jobs resource. `retrieve` and `triggerAction` responses' `job`
51
63
  * field gains a `.wait()` helper — previously only job-creating endpoints
package/lib/job.d.mts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"job.d.mts","sourceRoot":"","sources":["../src/lib/job.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,sBAAkB;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,gCAA4B;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,wCAAoC;AAClE,OAAO,EACL,IAAI,EACJ,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,wBAAwB,EAC9B,8BAA0B;AAE3B,MAAM,WAAW,WAAW;IAC1B,sDAAsD;IACtD,U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CAAC,GAAG;IAAE,GAAG,EAAE,UAAU,CAAA;CAAE,CAAC;AAE1E;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS;IAAE,GAAG,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,EAC7E,MAAM,EAAE,QAAQ,EAChB,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,EACtB,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAMxB;AAED;;;;;;GAMG;AACH,qBAAa,YAAa,SAAQ,IAAI;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAI3F,aAAa,CACpB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,sBAAsB,EAC9B,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CAAC,OAAO,CAAC,wBAAwB,CAAC,CAAC;CAGjD"}
package/lib/job.d.ts CHANGED
@@ -2,15 +2,24 @@ import type { Scenario } from "../client.js";
2
2
  import type { APIPromise } from "../core/api-promise.js";
3
3
  import type { RequestOptions } from "../internal/request-options.js";
4
4
  import { Jobs, type JobRetrieveResponse, type JobTriggerActionParams, type JobTriggerActionResponse } from "../resources/jobs.js";
5
+ import { type Scope } from "./scope.js";
5
6
  export interface WaitOptions {
6
7
  /** Polling interval in milliseconds. Default: 3000 */
7
8
  intervalMs?: number;
8
9
  /** Maximum wait time in milliseconds. Default: 120000 */
9
10
  timeoutMs?: number;
11
+ /**
12
+ * Override the project scope used for the polling requests. Defaults to
13
+ * the scope captured on the job (per-call override on the originating
14
+ * call, else the client's default project).
15
+ */
16
+ projectId?: string;
10
17
  }
11
18
  /** Job methods added on top of the original job fields. */
12
19
  export declare class JobMethods {
13
20
  /** @internal */ readonly _client: Scenario;
21
+ /** @internal scope captured from the originating call — replayed on every `.wait()` poll. */
22
+ readonly _scope?: Scope;
14
23
  /**
15
24
  * Poll until the job reaches a terminal status (success, failure, or canceled).
16
25
  *
@@ -22,8 +31,8 @@ export declare class JobMethods {
22
31
  * ```
23
32
  */
24
33
  wait(this: Job, options?: WaitOptions): Promise<Job>;
25
- /** @internal Create a Job from raw job data. */
26
- static from(client: Scenario, data: JobRetrieveResponse['job']): Job;
34
+ /** @internal Create a Job from raw job data, optionally remembering the originating scope. */
35
+ static from(client: Scenario, data: JobRetrieveResponse['job'], scope?: Scope): Job;
27
36
  }
28
37
  /** A job with all original fields plus `.wait()`. */
29
38
  export type Job = JobRetrieveResponse.Job & JobMethods;
@@ -39,13 +48,16 @@ export type WithJob<T extends {
39
48
  };
40
49
  /**
41
50
  * @internal Wrap `_thenUnwrap` to replace `response.job` with an enhanced Job.
51
+ * Captures the effective scope (per-call override or client default) so
52
+ * `.wait()` can replay it on every poll — keeping follow-up calls in sync
53
+ * with the project the job was originally created in.
42
54
  */
43
55
  export declare function enhanceJob<T extends {
44
56
  job: {
45
57
  jobId: string;
46
58
  status: string;
47
59
  };
48
- }>(client: Scenario, promise: APIPromise<T>): APIPromise<WithJob<T>>;
60
+ }>(client: Scenario, promise: APIPromise<T>, options?: RequestOptions): APIPromise<WithJob<T>>;
49
61
  /**
50
62
  * Enhanced Jobs resource. `retrieve` and `triggerAction` responses' `job`
51
63
  * field gains a `.wait()` helper — previously only job-creating endpoints
package/lib/job.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"job.d.ts","sourceRoot":"","sources":["../src/lib/job.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,qBAAkB;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,+BAA4B;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,uCAAoC;AAClE,OAAO,EACL,IAAI,EACJ,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,wBAAwB,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