@venizia/ignis 0.4.8-9 → 0.4.8

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 (194) hide show
  1. package/dist/esm/base/applications/base.js.map +1 -1
  2. package/dist/esm/components/api-reference/common/types.d.ts +6 -3
  3. package/dist/esm/components/api-reference/common/types.js.map +1 -1
  4. package/dist/esm/components/api-reference/component.js +8 -3
  5. package/dist/esm/components/api-reference/component.js.map +1 -1
  6. package/dist/esm/components/auth/authenticate/component.js +3 -2
  7. package/dist/esm/components/auth/authenticate/component.js.map +1 -1
  8. package/dist/esm/components/auth/authenticate/controllers/factory.d.ts +3 -3
  9. package/dist/esm/components/auth/authenticate/controllers/factory.js +1 -1
  10. package/dist/esm/components/auth/authenticate/controllers/factory.js.map +1 -1
  11. package/dist/esm/components/auth/authenticate/services/bearer/abstract.service.d.ts +5 -3
  12. package/dist/esm/components/auth/authenticate/services/bearer/abstract.service.js +18 -1
  13. package/dist/esm/components/auth/authenticate/services/bearer/abstract.service.js.map +1 -1
  14. package/dist/esm/components/auth/authorize/adapters/common/types.d.ts +1 -2
  15. package/dist/esm/components/auth/authorize/adapters/common/types.js.map +1 -1
  16. package/dist/esm/components/mail/common/constants.d.ts +24 -14
  17. package/dist/esm/components/mail/common/constants.js +19 -32
  18. package/dist/esm/components/mail/common/constants.js.map +1 -1
  19. package/dist/esm/components/mail/common/errors.d.ts +10 -1
  20. package/dist/esm/components/mail/common/errors.js +7 -1
  21. package/dist/esm/components/mail/common/errors.js.map +1 -1
  22. package/dist/esm/components/mail/common/types/message.d.ts +4 -4
  23. package/dist/esm/components/mail/common/types/message.js.map +1 -1
  24. package/dist/esm/components/mail/common/types/options.d.ts +54 -10
  25. package/dist/esm/components/mail/common/types/options.js.map +1 -1
  26. package/dist/esm/components/mail/common/types/queue.d.ts +23 -12
  27. package/dist/esm/components/mail/common/types/queue.js.map +1 -1
  28. package/dist/esm/components/mail/common/types/template.d.ts +5 -4
  29. package/dist/esm/components/mail/common/types/template.js.map +1 -1
  30. package/dist/esm/components/mail/common/types/verification.d.ts +1 -0
  31. package/dist/esm/components/mail/common/types/verification.js.map +1 -1
  32. package/dist/esm/components/mail/component.js +11 -2
  33. package/dist/esm/components/mail/component.js.map +1 -1
  34. package/dist/esm/components/mail/helpers/executors/bull-mq-executor.helper.d.ts +1 -1
  35. package/dist/esm/components/mail/helpers/executors/bull-mq-executor.helper.js +15 -28
  36. package/dist/esm/components/mail/helpers/executors/bull-mq-executor.helper.js.map +1 -1
  37. package/dist/esm/components/mail/helpers/executors/internal-queue-executor.helper.d.ts +2 -0
  38. package/dist/esm/components/mail/helpers/executors/internal-queue-executor.helper.js +17 -10
  39. package/dist/esm/components/mail/helpers/executors/internal-queue-executor.helper.js.map +1 -1
  40. package/dist/esm/components/mail/helpers/transporters/amazon-ses-transporter.helper.js +11 -6
  41. package/dist/esm/components/mail/helpers/transporters/amazon-ses-transporter.helper.js.map +1 -1
  42. package/dist/esm/components/mail/helpers/transporters/mailgun-transporter.helper.d.ts +2 -3
  43. package/dist/esm/components/mail/helpers/transporters/mailgun-transporter.helper.js +15 -6
  44. package/dist/esm/components/mail/helpers/transporters/mailgun-transporter.helper.js.map +1 -1
  45. package/dist/esm/components/mail/helpers/transporters/nodemail-transporter.helper.d.ts +2 -3
  46. package/dist/esm/components/mail/helpers/transporters/nodemail-transporter.helper.js +2 -2
  47. package/dist/esm/components/mail/helpers/transporters/nodemail-transporter.helper.js.map +1 -1
  48. package/dist/esm/components/mail/providers/mail-queue-executor.provider.d.ts +2 -2
  49. package/dist/esm/components/mail/providers/mail-queue-executor.provider.js +7 -9
  50. package/dist/esm/components/mail/providers/mail-queue-executor.provider.js.map +1 -1
  51. package/dist/esm/components/mail/providers/mail-transporter.provider.js +7 -7
  52. package/dist/esm/components/mail/providers/mail-transporter.provider.js.map +1 -1
  53. package/dist/esm/components/mail/services/generators/numeric-code.d.ts +1 -6
  54. package/dist/esm/components/mail/services/generators/numeric-code.js +3 -31
  55. package/dist/esm/components/mail/services/generators/numeric-code.js.map +1 -1
  56. package/dist/esm/components/mail/services/generators/random-token.d.ts +4 -1
  57. package/dist/esm/components/mail/services/generators/random-token.js +9 -6
  58. package/dist/esm/components/mail/services/generators/random-token.js.map +1 -1
  59. package/dist/esm/components/mail/services/mail.service.d.ts +1 -2
  60. package/dist/esm/components/mail/services/mail.service.js +21 -19
  61. package/dist/esm/components/mail/services/mail.service.js.map +1 -1
  62. package/dist/esm/components/mail/services/template.service.d.ts +7 -5
  63. package/dist/esm/components/mail/services/template.service.js +24 -16
  64. package/dist/esm/components/mail/services/template.service.js.map +1 -1
  65. package/dist/esm/components/mail/utilities/attachment.utility.js +8 -6
  66. package/dist/esm/components/mail/utilities/attachment.utility.js.map +1 -1
  67. package/dist/esm/components/mail/utilities/header.utility.d.ts +14 -0
  68. package/dist/esm/components/mail/utilities/header.utility.js +44 -0
  69. package/dist/esm/components/mail/utilities/header.utility.js.map +1 -0
  70. package/dist/esm/components/mail/utilities/index.d.ts +1 -0
  71. package/dist/esm/components/mail/utilities/index.js +1 -0
  72. package/dist/esm/components/mail/utilities/index.js.map +1 -1
  73. package/dist/esm/components/mail/utilities/mime.utility.d.ts +5 -1
  74. package/dist/esm/components/mail/utilities/mime.utility.js +12 -58
  75. package/dist/esm/components/mail/utilities/mime.utility.js.map +1 -1
  76. package/dist/esm/components/mail/utilities/type.utility.d.ts +2 -3
  77. package/dist/esm/components/mail/utilities/type.utility.js +6 -7
  78. package/dist/esm/components/mail/utilities/type.utility.js.map +1 -1
  79. package/dist/esm/components/socket-io/handlers/bun.handler.d.ts +13 -3
  80. package/dist/esm/components/socket-io/handlers/bun.handler.js.map +1 -1
  81. package/dist/esm/components/static-asset/common/constants.d.ts +51 -24
  82. package/dist/esm/components/static-asset/common/constants.js +75 -47
  83. package/dist/esm/components/static-asset/common/constants.js.map +1 -1
  84. package/dist/esm/components/static-asset/common/errors.d.ts +30 -35
  85. package/dist/esm/components/static-asset/common/errors.js +31 -33
  86. package/dist/esm/components/static-asset/common/errors.js.map +1 -1
  87. package/dist/esm/components/static-asset/common/index.d.ts +1 -1
  88. package/dist/esm/components/static-asset/common/index.js +1 -1
  89. package/dist/esm/components/static-asset/common/index.js.map +1 -1
  90. package/dist/esm/components/static-asset/common/keys.d.ts +10 -2
  91. package/dist/esm/components/static-asset/common/keys.js +10 -2
  92. package/dist/esm/components/static-asset/common/keys.js.map +1 -1
  93. package/dist/esm/components/static-asset/common/types.d.ts +267 -147
  94. package/dist/esm/components/static-asset/common/types.js.map +1 -1
  95. package/dist/esm/components/static-asset/common/validation.d.ts +10 -0
  96. package/dist/esm/components/static-asset/common/validation.js +8 -0
  97. package/dist/esm/components/static-asset/common/validation.js.map +1 -0
  98. package/dist/esm/components/static-asset/component.d.ts +4 -2
  99. package/dist/esm/components/static-asset/component.js +26 -31
  100. package/dist/esm/components/static-asset/component.js.map +1 -1
  101. package/dist/esm/components/static-asset/controller/factory.d.ts +37 -79
  102. package/dist/esm/components/static-asset/controller/factory.js +26 -917
  103. package/dist/esm/components/static-asset/controller/factory.js.map +1 -1
  104. package/dist/esm/components/static-asset/controller/index.d.ts +1 -0
  105. package/dist/esm/components/static-asset/controller/index.js +1 -0
  106. package/dist/esm/components/static-asset/controller/index.js.map +1 -1
  107. package/dist/esm/components/static-asset/controller/routes/context.d.ts +62 -0
  108. package/dist/esm/components/static-asset/controller/routes/context.js +45 -0
  109. package/dist/esm/components/static-asset/controller/routes/context.js.map +1 -0
  110. package/dist/esm/components/static-asset/controller/routes/definition.d.ts +40 -0
  111. package/dist/esm/components/static-asset/controller/routes/definition.js +83 -0
  112. package/dist/esm/components/static-asset/controller/routes/definition.js.map +1 -0
  113. package/dist/esm/components/static-asset/controller/routes/direct-upload.d.ts +3 -0
  114. package/dist/esm/components/static-asset/controller/routes/direct-upload.js +153 -0
  115. package/dist/esm/components/static-asset/controller/routes/direct-upload.js.map +1 -0
  116. package/dist/esm/components/static-asset/controller/routes/labels.d.ts +16 -0
  117. package/dist/esm/components/static-asset/controller/routes/labels.js +19 -0
  118. package/dist/esm/components/static-asset/controller/routes/labels.js.map +1 -0
  119. package/dist/esm/components/static-asset/controller/routes/objects.d.ts +7 -0
  120. package/dist/esm/components/static-asset/controller/routes/objects.js +193 -0
  121. package/dist/esm/components/static-asset/controller/routes/objects.js.map +1 -0
  122. package/dist/esm/components/static-asset/controller/routes/serve.d.ts +29 -0
  123. package/dist/esm/components/static-asset/controller/routes/serve.js +152 -0
  124. package/dist/esm/components/static-asset/controller/routes/serve.js.map +1 -0
  125. package/dist/esm/components/static-asset/controller/routes/table.d.ts +12 -0
  126. package/dist/esm/components/static-asset/controller/routes/table.js +52 -0
  127. package/dist/esm/components/static-asset/controller/routes/table.js.map +1 -0
  128. package/dist/esm/components/static-asset/controller/routes/upload.d.ts +10 -0
  129. package/dist/esm/components/static-asset/controller/routes/upload.js +175 -0
  130. package/dist/esm/components/static-asset/controller/routes/upload.js.map +1 -0
  131. package/dist/esm/components/static-asset/index.d.ts +2 -1
  132. package/dist/esm/components/static-asset/index.js +2 -1
  133. package/dist/esm/components/static-asset/index.js.map +1 -1
  134. package/dist/esm/components/static-asset/models/base.model.d.ts +4 -4
  135. package/dist/esm/components/static-asset/models/base.model.js.map +1 -1
  136. package/dist/esm/components/static-asset/services/commitment.service.d.ts +103 -0
  137. package/dist/esm/components/static-asset/services/commitment.service.js +252 -0
  138. package/dist/esm/components/static-asset/services/commitment.service.js.map +1 -0
  139. package/dist/esm/components/static-asset/services/index.d.ts +3 -0
  140. package/dist/esm/components/static-asset/services/index.js +3 -0
  141. package/dist/esm/components/static-asset/services/index.js.map +1 -0
  142. package/dist/esm/components/static-asset/services/policy.service.d.ts +45 -0
  143. package/dist/esm/components/static-asset/services/policy.service.js +104 -0
  144. package/dist/esm/components/static-asset/services/policy.service.js.map +1 -0
  145. package/dist/esm/components/static-asset/utilities/commit-token.utility.d.ts +28 -0
  146. package/dist/esm/components/static-asset/utilities/commit-token.utility.js +112 -0
  147. package/dist/esm/components/static-asset/utilities/commit-token.utility.js.map +1 -0
  148. package/dist/esm/components/static-asset/utilities/entry.utility.d.ts +69 -0
  149. package/dist/esm/components/static-asset/utilities/entry.utility.js +160 -0
  150. package/dist/esm/components/static-asset/utilities/entry.utility.js.map +1 -0
  151. package/dist/esm/components/static-asset/utilities/index.d.ts +6 -0
  152. package/dist/esm/components/static-asset/utilities/index.js +6 -0
  153. package/dist/esm/components/static-asset/utilities/index.js.map +1 -0
  154. package/dist/esm/components/static-asset/{ingest.d.ts → utilities/ingest.utility.d.ts} +5 -5
  155. package/dist/esm/components/static-asset/{ingest.js → utilities/ingest.utility.js} +12 -10
  156. package/dist/esm/components/static-asset/utilities/ingest.utility.js.map +1 -0
  157. package/dist/esm/components/static-asset/{controller/key-scope.d.ts → utilities/key-scope.utility.d.ts} +21 -2
  158. package/dist/esm/components/static-asset/utilities/key-scope.utility.js +74 -0
  159. package/dist/esm/components/static-asset/utilities/key-scope.utility.js.map +1 -0
  160. package/dist/esm/components/static-asset/{controller/meta-link.d.ts → utilities/meta-link.utility.d.ts} +9 -9
  161. package/dist/esm/components/static-asset/{controller/meta-link.js → utilities/meta-link.utility.js} +10 -10
  162. package/dist/esm/components/static-asset/utilities/meta-link.utility.js.map +1 -0
  163. package/dist/esm/components/static-asset/utilities/object-link.utility.d.ts +16 -0
  164. package/dist/esm/components/static-asset/utilities/object-link.utility.js +20 -0
  165. package/dist/esm/components/static-asset/utilities/object-link.utility.js.map +1 -0
  166. package/dist/esm/components/static-asset/utilities/pinned-file.utility.d.ts +39 -0
  167. package/dist/esm/components/static-asset/utilities/pinned-file.utility.js +53 -0
  168. package/dist/esm/components/static-asset/utilities/pinned-file.utility.js.map +1 -0
  169. package/dist/esm/components/static-asset/utilities/route-options.utility.d.ts +43 -0
  170. package/dist/esm/components/static-asset/utilities/route-options.utility.js +71 -0
  171. package/dist/esm/components/static-asset/utilities/route-options.utility.js.map +1 -0
  172. package/dist/esm/components/static-asset/utilities/toggle.utility.d.ts +5 -0
  173. package/dist/esm/components/static-asset/utilities/toggle.utility.js +5 -0
  174. package/dist/esm/components/static-asset/utilities/toggle.utility.js.map +1 -0
  175. package/dist/esm/testing/assert-application-boots.d.ts +2 -2
  176. package/dist/esm/testing/assert-application-boots.js +6 -2
  177. package/dist/esm/testing/assert-application-boots.js.map +1 -1
  178. package/dist/presets/app/preset.json +4 -4
  179. package/dist/presets/lib/preset.json +3 -3
  180. package/dist/presets/shared/preset.json +1 -1
  181. package/package.json +8 -8
  182. package/dist/esm/components/static-asset/common/commit-token.d.ts +0 -28
  183. package/dist/esm/components/static-asset/common/commit-token.js +0 -48
  184. package/dist/esm/components/static-asset/common/commit-token.js.map +0 -1
  185. package/dist/esm/components/static-asset/controller/base.definition.d.ts +0 -30
  186. package/dist/esm/components/static-asset/controller/base.definition.js +0 -307
  187. package/dist/esm/components/static-asset/controller/base.definition.js.map +0 -1
  188. package/dist/esm/components/static-asset/controller/key-scope.js +0 -41
  189. package/dist/esm/components/static-asset/controller/key-scope.js.map +0 -1
  190. package/dist/esm/components/static-asset/controller/meta-link.js.map +0 -1
  191. package/dist/esm/components/static-asset/controller/route-options.d.ts +0 -29
  192. package/dist/esm/components/static-asset/controller/route-options.js +0 -47
  193. package/dist/esm/components/static-asset/controller/route-options.js.map +0 -1
  194. package/dist/esm/components/static-asset/ingest.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commit-token.utility.js","sourceRoot":"","sources":["../../../../../src/components/static-asset/utilities/commit-token.utility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AACnF,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAOrD,yFAAyF;AACzF,MAAM,OAAO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,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,CAAC;QACzD,CAAC;QAED,IACE,CAAC,IAAI,CAAC,MAAM,CAAC;YACX,KAAK,EAAE,SAAS;YAChB,QAAQ,EAAE,6BAA6B,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;SAClE,CAAC,EACF,CAAC;YACD,MAAM,QAAQ,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,CAAC;QACzD,CAAC;QAED,MAAM,OAAO,GAAG,6BAA6B,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;QAE9D,IAAI,OAAO,CAAC,SAAS,IAAI,GAAG,EAAE,CAAC;YAC7B,MAAM,QAAQ,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,CAAC;QACzD,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF","sourcesContent":["import { Hash, HashAlgorithms, HashOutputEncodings } from '@venizia/ignis-helpers';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { StaticAssetTokenStages } from '../common/constants';\nimport { StaticAssetErrors } from '../common/errors';\nimport type {\n IStaticAssetCommitTokenPayload,\n IStaticAssetPin,\n TStaticAssetTokenMetadata,\n} from '../common/types';\n\n/** Signs and reads the token the commit route trusts instead of a key a caller names. */\nexport class StaticAssetCommitTokenUtility {\n private static encode(payload: IStaticAssetCommitTokenPayload): string {\n return Buffer.from(JSON.stringify(payload)).toString('base64url');\n }\n\n // `Hash.hmac` refuses an empty secret: an unkeyed signature is one anyone can compute.\n private static sign(opts: { body: string; secretKey: string }): string {\n return Hash.withAlgorithm(HashAlgorithms.SHA256).hmac({\n message: opts.body,\n secret: opts.secretKey,\n opts: { outputEncoding: HashOutputEncodings.BASE64URL },\n });\n }\n\n private static isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null;\n }\n\n private static isStringRecord(value: unknown): value is TStaticAssetTokenMetadata {\n return (\n StaticAssetCommitTokenUtility.isRecord(value) &&\n !Array.isArray(value) &&\n Object.values(value).every((entry) => typeof entry === 'string')\n );\n }\n\n /** A signed body that is not the current payload shape is refused as invalid: a token minted before the shape changed still carries a good signature. */\n private static parse(opts: { body: string }): IStaticAssetCommitTokenPayload {\n let parsed: unknown;\n\n try {\n parsed = JSON.parse(Buffer.from(opts.body, 'base64url').toString('utf8'));\n } catch {\n throw getError(StaticAssetErrors.INVALID_COMMIT_TOKEN);\n }\n\n if (!StaticAssetCommitTokenUtility.isRecord(parsed)) {\n throw getError(StaticAssetErrors.INVALID_COMMIT_TOKEN);\n }\n\n const { bucket, object, expiresAt, owner, metadata, stage, pin } = parsed;\n\n if (\n !StaticAssetCommitTokenUtility.isRecord(bucket) ||\n typeof bucket.name !== 'string' ||\n !StaticAssetCommitTokenUtility.isRecord(object) ||\n typeof object.key !== 'string' ||\n typeof expiresAt !== 'number' ||\n typeof owner !== 'string' ||\n !StaticAssetCommitTokenUtility.isStringRecord(metadata)\n ) {\n throw getError(StaticAssetErrors.INVALID_COMMIT_TOKEN);\n }\n\n if (stage === StaticAssetTokenStages.ISSUED) {\n return {\n bucket: { name: bucket.name },\n object: { key: object.key },\n expiresAt,\n owner,\n metadata,\n stage,\n };\n }\n\n // A validated token without its pin would commit unpinned content: it is no token.\n if (stage !== StaticAssetTokenStages.VALIDATED) {\n throw getError(StaticAssetErrors.INVALID_COMMIT_TOKEN);\n }\n\n return {\n bucket: { name: bucket.name },\n object: { key: object.key },\n expiresAt,\n owner,\n metadata,\n stage,\n pin: StaticAssetCommitTokenUtility.parsePin({ pin }),\n };\n }\n\n private static parsePin(opts: { pin: unknown }): IStaticAssetPin {\n const { pin } = opts;\n\n if (\n !StaticAssetCommitTokenUtility.isRecord(pin) ||\n typeof pin.etag !== 'string' ||\n (pin.versionId !== undefined && typeof pin.versionId !== 'string')\n ) {\n throw getError(StaticAssetErrors.INVALID_COMMIT_TOKEN);\n }\n\n return { etag: pin.etag, versionId: pin.versionId };\n }\n\n /** Signs the payload so the commit route can trust the key it is handed. */\n static build(opts: { payload: IStaticAssetCommitTokenPayload; secretKey: string }): string {\n const body = StaticAssetCommitTokenUtility.encode(opts.payload);\n\n return `${body}.${StaticAssetCommitTokenUtility.sign({ body, secretKey: opts.secretKey })}`;\n }\n\n /**\n * Reads a commit token back, or throws.\n *\n * Verification happens BEFORE any storage call, which is what makes the commit route refuse to be a\n * name prober: a forged token fails without a round trip, so timing says nothing about what exists.\n */\n static read(opts: {\n token: string;\n secretKey: string;\n now?: number;\n }): IStaticAssetCommitTokenPayload {\n const { token, secretKey, now = Date.now() } = opts;\n const parts = token.split('.');\n const [body, signature] = parts;\n\n if (parts.length !== 2 || !body || !signature) {\n throw getError(StaticAssetErrors.INVALID_COMMIT_TOKEN);\n }\n\n if (\n !Hash.equals({\n value: signature,\n expected: StaticAssetCommitTokenUtility.sign({ body, secretKey }),\n })\n ) {\n throw getError(StaticAssetErrors.INVALID_COMMIT_TOKEN);\n }\n\n const payload = StaticAssetCommitTokenUtility.parse({ body });\n\n if (payload.expiresAt <= now) {\n throw getError(StaticAssetErrors.EXPIRED_COMMIT_TOKEN);\n }\n\n return payload;\n }\n}\n"]}
@@ -0,0 +1,69 @@
1
+ import type { IObjectLocation, IStorageHelper } from '@venizia/ignis-helpers';
2
+ import type { TValueOrAsyncResolver } from '@venizia/ignis-helpers/common';
3
+ import type { IStaticAssetValidation, TMetaLinkConfig, TStaticAssetAuth, TStaticAssetDefineExtraRoutes, TStaticAssetDirectUploadOptions, TStaticAssetEntry, TStaticAssetObjectKeyResolver, TStaticAssetRouteConfig, TStaticAssetRouteKey, TStaticAssetStorageType } from '../common/index.js';
4
+ import type { TMetaLinkCompatibleSchema } from '../models/index.js';
5
+ import { StaticAssetUploadCommitService, StaticAssetUploadPolicyService } from '../services/index.js';
6
+ import type { z } from '@hono/zod-openapi';
7
+ /** One route after its toggle is read: whether it is registered, and what the application overrides. */
8
+ export interface IStaticAssetResolvedRoute {
9
+ isEnabled: boolean;
10
+ override: TStaticAssetRouteConfig;
11
+ }
12
+ /** An entry with every toggle read, every default applied and every cross-check made, so the component, the controller and the services read one thing. */
13
+ export interface IStaticAssetResolvedEntry<Schema extends TMetaLinkCompatibleSchema> {
14
+ name: string;
15
+ /** The mount path with exactly one leading slash. */
16
+ basePath: string;
17
+ rawObjectPath: boolean;
18
+ bucket: TValueOrAsyncResolver<string>;
19
+ /** Normalized: no leading slash, one trailing slash. */
20
+ keyPrefix?: string;
21
+ /** Folders allowed in an object key: the caller's `maxFolderDepth` plus the scope's own. */
22
+ objectKeyMaxDepth: number;
23
+ maxFolderDepth: number;
24
+ auth?: Pick<TStaticAssetAuth, 'authenticate' | 'authorize'> & {
25
+ isPublicRead: boolean;
26
+ };
27
+ routes: Partial<Record<TStaticAssetRouteKey, IStaticAssetResolvedRoute>>;
28
+ helper: IStorageHelper;
29
+ storage: TStaticAssetStorageType;
30
+ link: (opts: IObjectLocation) => string;
31
+ serverUpload?: {
32
+ maxBytes?: number;
33
+ maxFiles: number;
34
+ objectKey?: TStaticAssetObjectKeyResolver;
35
+ };
36
+ /** `authorize` is always present here: the entry's own, or the pass-through that `auth` makes safe. `validation` is present only when it is on. */
37
+ directUpload?: Omit<TStaticAssetDirectUploadOptions, 'authorize' | 'validation'> & {
38
+ authorize: NonNullable<TStaticAssetDirectUploadOptions['authorize']>;
39
+ validation?: IStaticAssetValidation<z.ZodType>;
40
+ };
41
+ metaLink?: TMetaLinkConfig<Schema>;
42
+ extend?: {
43
+ before?: TStaticAssetDefineExtraRoutes;
44
+ after?: TStaticAssetDefineExtraRoutes;
45
+ };
46
+ }
47
+ export declare class StaticAssetEntryUtility {
48
+ /** `staticAsset` and `static-asset` both become `StaticAssetController`; a name already ending in `Controller` keeps it. */
49
+ private static deriveName;
50
+ /** True when the entry's `auth` already decides who may call a route, which is what makes a missing `directUpload.authorize` safe. */
51
+ private static isGuarded;
52
+ /** Reads every toggle, applies every default and refuses what the types cannot (an entry written in plain JavaScript, or cast). */
53
+ static resolve<Schema extends TMetaLinkCompatibleSchema>(opts: {
54
+ key: string;
55
+ entry: TStaticAssetEntry<Schema>;
56
+ }): IStaticAssetResolvedEntry<Schema>;
57
+ /**
58
+ * The pair of services an entry's direct-upload routes run, or `undefined` when the entry has no
59
+ * direct upload. The one place they are constructed: the component binds what this returns and
60
+ * hands the same instances to the controller.
61
+ */
62
+ static buildDirectUploadServices<Schema extends TMetaLinkCompatibleSchema>(opts: {
63
+ resolved: IStaticAssetResolvedEntry<Schema>;
64
+ }): {
65
+ policyService: StaticAssetUploadPolicyService;
66
+ commitService: StaticAssetUploadCommitService<Schema>;
67
+ } | undefined;
68
+ }
69
+ //# sourceMappingURL=entry.utility.d.ts.map
@@ -0,0 +1,160 @@
1
+ import { BaseStorageHelper, StorageTypes } from '@venizia/ignis-helpers';
2
+ import { getError } from '@venizia/ignis-helpers/core';
3
+ import { StaticAssetDefaults, StaticAssetRouteKeys } from '../common/index.js';
4
+ import { StaticAssetUploadCommitService, StaticAssetUploadPolicyService } from '../services/index.js';
5
+ import { StaticAssetKeyScopeUtility } from './key-scope.utility.js';
6
+ import { StaticAssetObjectLinkUtility } from './object-link.utility.js';
7
+ import { StaticAssetToggleUtility } from './toggle.utility.js';
8
+ export class StaticAssetEntryUtility {
9
+ /** `staticAsset` and `static-asset` both become `StaticAssetController`; a name already ending in `Controller` keeps it. */
10
+ static deriveName(opts) {
11
+ const words = opts.key.split(/[^A-Za-z0-9]+/).filter((word) => word.length > 0);
12
+ const pascal = words.map((word) => `${word[0].toUpperCase()}${word.slice(1)}`).join('');
13
+ return pascal.endsWith('Controller') ? pascal : `${pascal}Controller`;
14
+ }
15
+ /** True when the entry's `auth` already decides who may call a route, which is what makes a missing `directUpload.authorize` safe. */
16
+ static isGuarded(opts) {
17
+ const { authenticate, authorize } = opts.auth ?? {};
18
+ const isAuthenticated = authenticate != null &&
19
+ authenticate.skip !== true &&
20
+ (authenticate.strategies?.length ?? 0) > 0;
21
+ const isAuthorized = authorize != null && !('skip' in authorize);
22
+ return isAuthenticated || isAuthorized;
23
+ }
24
+ /** Reads every toggle, applies every default and refuses what the types cannot (an entry written in plain JavaScript, or cast). */
25
+ static resolve(opts) {
26
+ const { key, entry } = opts;
27
+ const { helper, bucket, auth } = entry;
28
+ const name = entry.name ?? StaticAssetEntryUtility.deriveName({ key });
29
+ const { storageType } = helper;
30
+ if (storageType !== StorageTypes.BUN_S3 && storageType !== StorageTypes.DISK) {
31
+ throw getError({
32
+ message: `[${name}] helper must be a BunS3Helper or a DiskHelper | storageType: ${storageType}`,
33
+ });
34
+ }
35
+ const directUpload = StaticAssetToggleUtility.isUsed(entry.directUpload)
36
+ ? entry.directUpload
37
+ : undefined;
38
+ // A policy is a POST policy, which only S3 can sign.
39
+ if (directUpload && storageType !== StorageTypes.BUN_S3) {
40
+ throw getError({
41
+ message: `[${name}] directUpload needs a BunS3Helper | a POST policy is an S3 feature, and this helper is ${storageType}`,
42
+ });
43
+ }
44
+ // Its pending objects live in the same bucket: the scope is what keeps them out of the routes.
45
+ if (directUpload && entry.keyPrefix === undefined) {
46
+ throw getError({
47
+ message: `[${name}] directUpload needs keyPrefix | the pending prefix stays out of what the routes serve only when the entry has a scope of its own`,
48
+ });
49
+ }
50
+ if (directUpload && typeof directUpload.resolvers?.owner !== 'function') {
51
+ throw getError({
52
+ message: `[${name}] directUpload needs resolvers.owner | a token is signed for one owner, and the commit refuses any other`,
53
+ });
54
+ }
55
+ if (directUpload && directUpload.authorize === undefined) {
56
+ if (!StaticAssetEntryUtility.isGuarded({ auth })) {
57
+ throw getError({
58
+ message: `[${name}] directUpload needs authorize or auth | a route that hands out a write credential has no safe default for who may call it`,
59
+ });
60
+ }
61
+ }
62
+ const scope = entry.keyPrefix === undefined
63
+ ? undefined
64
+ : StaticAssetKeyScopeUtility.normalizePrefix({
65
+ keyPrefix: entry.keyPrefix,
66
+ helper,
67
+ scope: name,
68
+ });
69
+ const serverUpload = StaticAssetToggleUtility.isUsed(entry.serverUpload)
70
+ ? entry.serverUpload
71
+ : undefined;
72
+ const maxFolderDepth = entry.maxFolderDepth ?? BaseStorageHelper.DEFAULT_MAX_FOLDER_DEPTH;
73
+ const basePath = StaticAssetObjectLinkUtility.normalizeBasePath({ basePath: entry.basePath });
74
+ const rawObjectPath = entry.rawObjectPath ?? false;
75
+ const routes = {};
76
+ for (const routeKey of StaticAssetRouteKeys.ALL) {
77
+ const toggle = entry.routes?.[routeKey];
78
+ if (toggle) {
79
+ routes[routeKey] = {
80
+ isEnabled: StaticAssetToggleUtility.isUsed(toggle),
81
+ override: StaticAssetToggleUtility.pick(toggle) ?? {},
82
+ };
83
+ }
84
+ }
85
+ const metaLink = StaticAssetToggleUtility.isUsed(entry.metaLink) ? entry.metaLink : undefined;
86
+ const validation = directUpload && StaticAssetToggleUtility.isUsed(directUpload.validation)
87
+ ? directUpload.validation
88
+ : undefined;
89
+ return {
90
+ name,
91
+ basePath,
92
+ rawObjectPath,
93
+ bucket,
94
+ keyPrefix: scope?.keyPrefix,
95
+ maxFolderDepth,
96
+ // `maxFolderDepth` counts the caller's folders; the scope's own and the framework's uuid folder are not input.
97
+ objectKeyMaxDepth: maxFolderDepth + (scope?.depth ?? 0) + 1,
98
+ auth: auth && {
99
+ authenticate: auth.authenticate,
100
+ authorize: auth.authorize,
101
+ isPublicRead: StaticAssetToggleUtility.isUsed(auth.publicRead),
102
+ },
103
+ routes,
104
+ helper,
105
+ storage: storageType,
106
+ link: entry.link ??
107
+ ((location) => StaticAssetObjectLinkUtility.build({
108
+ basePath,
109
+ bucket: location.bucket,
110
+ object: location.object,
111
+ rawObjectPath,
112
+ })),
113
+ serverUpload: serverUpload && {
114
+ maxBytes: serverUpload.maxBytes,
115
+ maxFiles: serverUpload.maxFiles ?? StaticAssetDefaults.MAX_UPLOAD_FILES,
116
+ objectKey: serverUpload.objectKey,
117
+ },
118
+ directUpload: directUpload && {
119
+ ...directUpload,
120
+ validation,
121
+ authorize: directUpload.authorize ?? (() => true),
122
+ },
123
+ metaLink,
124
+ extend: entry.extend,
125
+ };
126
+ }
127
+ /**
128
+ * The pair of services an entry's direct-upload routes run, or `undefined` when the entry has no
129
+ * direct upload. The one place they are constructed: the component binds what this returns and
130
+ * hands the same instances to the controller.
131
+ */
132
+ static buildDirectUploadServices(opts) {
133
+ const { resolved } = opts;
134
+ const { keyPrefix, directUpload } = resolved;
135
+ if (!directUpload || keyPrefix === undefined) {
136
+ return undefined;
137
+ }
138
+ return {
139
+ policyService: new StaticAssetUploadPolicyService({
140
+ scope: resolved.name,
141
+ helper: resolved.helper,
142
+ bucket: resolved.bucket,
143
+ keyPrefix,
144
+ directUpload,
145
+ }),
146
+ commitService: new StaticAssetUploadCommitService({
147
+ scope: resolved.name,
148
+ helper: resolved.helper,
149
+ bucket: resolved.bucket,
150
+ keyPrefix,
151
+ objectKeyMaxDepth: resolved.objectKeyMaxDepth,
152
+ directUpload,
153
+ storage: resolved.storage,
154
+ metaLink: resolved.metaLink,
155
+ link: resolved.link,
156
+ }),
157
+ };
158
+ }
159
+ }
160
+ //# sourceMappingURL=entry.utility.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entry.utility.js","sourceRoot":"","sources":["../../../../../src/components/static-asset/utilities/entry.utility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAGzE,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AActE,OAAO,EAAE,8BAA8B,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAC;AAC7F,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAoC5D,MAAM,OAAO,uBAAuB;IAClC,4HAA4H;IACpH,MAAM,CAAC,UAAU,CAA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AAE,GAAG,QAAQ,CAAC;QAE7C,IAAI,CAAC,YAAY,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;YAC7C,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,OAAO;YACL,aAAa,EAAE,IAAI,8BAA8B,CAAC;gBAChD,KAAK,EAAE,QAAQ,CAAC,IAAI;gBACpB,MAAM,EAAE,QAAQ,CAAC,MAAM;gBACvB,MAAM,EAAE,QAAQ,CAAC,MAAM;gBACvB,SAAS;gBACT,YAAY;aACb,CAAC;YACF,aAAa,EAAE,IAAI,8BAA8B,CAAS;gBACxD,KAAK,EAAE,QAAQ,CAAC,IAAI;gBACpB,MAAM,EAAE,QAAQ,CAAC,MAAM;gBACvB,MAAM,EAAE,QAAQ,CAAC,MAAM;gBACvB,SAAS;gBACT,iBAAiB,EAAE,QAAQ,CAAC,iBAAiB;gBAC7C,YAAY;gBACZ,OAAO,EAAE,QAAQ,CAAC,OAAO;gBACzB,QAAQ,EAAE,QAAQ,CAAC,QAAQ;gBAC3B,IAAI,EAAE,QAAQ,CAAC,IAAI;aACpB,CAAC;SACH,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { BaseStorageHelper, StorageTypes } from '@venizia/ignis-helpers';\nimport type { IObjectLocation, IStorageHelper } from '@venizia/ignis-helpers';\nimport type { TValueOrAsyncResolver } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { StaticAssetDefaults, StaticAssetRouteKeys } from '../common';\nimport type {\n IStaticAssetValidation,\n TMetaLinkConfig,\n TStaticAssetAuth,\n TStaticAssetDefineExtraRoutes,\n TStaticAssetDirectUploadOptions,\n TStaticAssetEntry,\n TStaticAssetObjectKeyResolver,\n TStaticAssetRouteConfig,\n TStaticAssetRouteKey,\n TStaticAssetStorageType,\n} from '../common';\nimport type { TMetaLinkCompatibleSchema } from '../models';\nimport { StaticAssetUploadCommitService, StaticAssetUploadPolicyService } from '../services';\nimport { StaticAssetKeyScopeUtility } from './key-scope.utility';\nimport { StaticAssetObjectLinkUtility } from './object-link.utility';\nimport { StaticAssetToggleUtility } from './toggle.utility';\nimport type { z } from '@hono/zod-openapi';\n\n/** One route after its toggle is read: whether it is registered, and what the application overrides. */\nexport interface IStaticAssetResolvedRoute {\n isEnabled: boolean;\n override: TStaticAssetRouteConfig;\n}\n\n/** An entry with every toggle read, every default applied and every cross-check made, so the component, the controller and the services read one thing. */\nexport interface IStaticAssetResolvedEntry<Schema extends TMetaLinkCompatibleSchema> {\n name: string;\n /** The mount path with exactly one leading slash. */\n basePath: string;\n rawObjectPath: boolean;\n bucket: TValueOrAsyncResolver<string>;\n /** Normalized: no leading slash, one trailing slash. */\n keyPrefix?: string;\n /** Folders allowed in an object key: the caller's `maxFolderDepth` plus the scope's own. */\n objectKeyMaxDepth: number;\n maxFolderDepth: number;\n auth?: Pick<TStaticAssetAuth, 'authenticate' | 'authorize'> & { isPublicRead: boolean };\n routes: Partial<Record<TStaticAssetRouteKey, IStaticAssetResolvedRoute>>;\n helper: IStorageHelper;\n storage: TStaticAssetStorageType;\n link: (opts: IObjectLocation) => string;\n serverUpload?: { maxBytes?: number; maxFiles: number; objectKey?: TStaticAssetObjectKeyResolver };\n /** `authorize` is always present here: the entry's own, or the pass-through that `auth` makes safe. `validation` is present only when it is on. */\n directUpload?: Omit<TStaticAssetDirectUploadOptions, 'authorize' | 'validation'> & {\n authorize: NonNullable<TStaticAssetDirectUploadOptions['authorize']>;\n validation?: IStaticAssetValidation<z.ZodType>;\n };\n metaLink?: TMetaLinkConfig<Schema>;\n extend?: { before?: TStaticAssetDefineExtraRoutes; after?: TStaticAssetDefineExtraRoutes };\n}\n\nexport class StaticAssetEntryUtility {\n /** `staticAsset` and `static-asset` both become `StaticAssetController`; a name already ending in `Controller` keeps it. */\n private static deriveName(opts: { key: string }): string {\n const words = opts.key.split(/[^A-Za-z0-9]+/).filter((word) => word.length > 0);\n const pascal = words.map((word) => `${word[0].toUpperCase()}${word.slice(1)}`).join('');\n\n return pascal.endsWith('Controller') ? pascal : `${pascal}Controller`;\n }\n\n /** True when the entry's `auth` already decides who may call a route, which is what makes a missing `directUpload.authorize` safe. */\n private static isGuarded(opts: { auth?: TStaticAssetAuth }): boolean {\n const { authenticate, authorize } = opts.auth ?? {};\n const isAuthenticated =\n authenticate != null &&\n authenticate.skip !== true &&\n (authenticate.strategies?.length ?? 0) > 0;\n const isAuthorized = authorize != null && !('skip' in authorize);\n\n return isAuthenticated || isAuthorized;\n }\n\n /** Reads every toggle, applies every default and refuses what the types cannot (an entry written in plain JavaScript, or cast). */\n static resolve<Schema extends TMetaLinkCompatibleSchema>(opts: {\n key: string;\n entry: TStaticAssetEntry<Schema>;\n }): IStaticAssetResolvedEntry<Schema> {\n const { key, entry } = opts;\n const { helper, bucket, auth } = entry;\n const name = entry.name ?? StaticAssetEntryUtility.deriveName({ key });\n const { storageType } = helper;\n\n if (storageType !== StorageTypes.BUN_S3 && storageType !== StorageTypes.DISK) {\n throw getError({\n message: `[${name}] helper must be a BunS3Helper or a DiskHelper | storageType: ${storageType}`,\n });\n }\n\n const directUpload = StaticAssetToggleUtility.isUsed(entry.directUpload)\n ? entry.directUpload\n : undefined;\n\n // A policy is a POST policy, which only S3 can sign.\n if (directUpload && storageType !== StorageTypes.BUN_S3) {\n throw getError({\n message: `[${name}] directUpload needs a BunS3Helper | a POST policy is an S3 feature, and this helper is ${storageType}`,\n });\n }\n\n // Its pending objects live in the same bucket: the scope is what keeps them out of the routes.\n if (directUpload && entry.keyPrefix === undefined) {\n throw getError({\n message: `[${name}] directUpload needs keyPrefix | the pending prefix stays out of what the routes serve only when the entry has a scope of its own`,\n });\n }\n\n if (directUpload && typeof directUpload.resolvers?.owner !== 'function') {\n throw getError({\n message: `[${name}] directUpload needs resolvers.owner | a token is signed for one owner, and the commit refuses any other`,\n });\n }\n\n if (directUpload && directUpload.authorize === undefined) {\n if (!StaticAssetEntryUtility.isGuarded({ auth })) {\n throw getError({\n message: `[${name}] directUpload needs authorize or auth | a route that hands out a write credential has no safe default for who may call it`,\n });\n }\n }\n\n const scope =\n entry.keyPrefix === undefined\n ? undefined\n : StaticAssetKeyScopeUtility.normalizePrefix({\n keyPrefix: entry.keyPrefix,\n helper,\n scope: name,\n });\n const serverUpload = StaticAssetToggleUtility.isUsed(entry.serverUpload)\n ? entry.serverUpload\n : undefined;\n const maxFolderDepth = entry.maxFolderDepth ?? BaseStorageHelper.DEFAULT_MAX_FOLDER_DEPTH;\n const basePath = StaticAssetObjectLinkUtility.normalizeBasePath({ basePath: entry.basePath });\n const rawObjectPath = entry.rawObjectPath ?? false;\n\n const routes: IStaticAssetResolvedEntry<Schema>['routes'] = {};\n\n for (const routeKey of StaticAssetRouteKeys.ALL) {\n const toggle = entry.routes?.[routeKey];\n\n if (toggle) {\n routes[routeKey] = {\n isEnabled: StaticAssetToggleUtility.isUsed(toggle),\n override: StaticAssetToggleUtility.pick(toggle) ?? {},\n };\n }\n }\n\n const metaLink = StaticAssetToggleUtility.isUsed(entry.metaLink) ? entry.metaLink : undefined;\n const validation =\n directUpload && StaticAssetToggleUtility.isUsed(directUpload.validation)\n ? directUpload.validation\n : undefined;\n\n return {\n name,\n basePath,\n rawObjectPath,\n bucket,\n keyPrefix: scope?.keyPrefix,\n maxFolderDepth,\n // `maxFolderDepth` counts the caller's folders; the scope's own and the framework's uuid folder are not input.\n objectKeyMaxDepth: maxFolderDepth + (scope?.depth ?? 0) + 1,\n auth: auth && {\n authenticate: auth.authenticate,\n authorize: auth.authorize,\n isPublicRead: StaticAssetToggleUtility.isUsed(auth.publicRead),\n },\n routes,\n helper,\n storage: storageType,\n link:\n entry.link ??\n ((location) =>\n StaticAssetObjectLinkUtility.build({\n basePath,\n bucket: location.bucket,\n object: location.object,\n rawObjectPath,\n })),\n serverUpload: serverUpload && {\n maxBytes: serverUpload.maxBytes,\n maxFiles: serverUpload.maxFiles ?? StaticAssetDefaults.MAX_UPLOAD_FILES,\n objectKey: serverUpload.objectKey,\n },\n directUpload: directUpload && {\n ...directUpload,\n validation,\n authorize: directUpload.authorize ?? (() => true),\n },\n metaLink,\n extend: entry.extend,\n };\n }\n\n /**\n * The pair of services an entry's direct-upload routes run, or `undefined` when the entry has no\n * direct upload. The one place they are constructed: the component binds what this returns and\n * hands the same instances to the controller.\n */\n static buildDirectUploadServices<Schema extends TMetaLinkCompatibleSchema>(opts: {\n resolved: IStaticAssetResolvedEntry<Schema>;\n }):\n | {\n policyService: StaticAssetUploadPolicyService;\n commitService: StaticAssetUploadCommitService<Schema>;\n }\n | undefined {\n const { resolved } = opts;\n const { keyPrefix, directUpload } = resolved;\n\n if (!directUpload || keyPrefix === undefined) {\n return undefined;\n }\n\n return {\n policyService: new StaticAssetUploadPolicyService({\n scope: resolved.name,\n helper: resolved.helper,\n bucket: resolved.bucket,\n keyPrefix,\n directUpload,\n }),\n commitService: new StaticAssetUploadCommitService<Schema>({\n scope: resolved.name,\n helper: resolved.helper,\n bucket: resolved.bucket,\n keyPrefix,\n objectKeyMaxDepth: resolved.objectKeyMaxDepth,\n directUpload,\n storage: resolved.storage,\n metaLink: resolved.metaLink,\n link: resolved.link,\n }),\n };\n }\n}\n"]}
@@ -0,0 +1,6 @@
1
+ export * from './commit-token.utility.js';
2
+ export * from './ingest.utility.js';
3
+ export * from './object-link.utility.js';
4
+ export * from './pinned-file.utility.js';
5
+ export * from './toggle.utility.js';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,6 @@
1
+ export * from './commit-token.utility.js';
2
+ export * from './ingest.utility.js';
3
+ export * from './object-link.utility.js';
4
+ export * from './pinned-file.utility.js';
5
+ export * from './toggle.utility.js';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/components/static-asset/utilities/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC","sourcesContent":["export * from './commit-token.utility';\nexport * from './ingest.utility';\nexport * from './object-link.utility';\nexport * from './pinned-file.utility';\nexport * from './toggle.utility';\n"]}
@@ -6,12 +6,12 @@ import { type IBucketRef, type IObjectRef, type IFileStat, type IStorageHelper,
6
6
  * This does NOT write a meta link. The columns an application attaches to an object - a principal,
7
7
  * a variant - come from its own domain, not from the object, so the row stays the caller's.
8
8
  */
9
- export interface IIngestFromUrlResult {
9
+ export interface IStaticAssetIngestFromUrlResult {
10
10
  upload: IUploadResult;
11
11
  stat: IFileStat;
12
12
  }
13
13
  /** Where a fetched object lands, and what it is attached to. */
14
- export interface IIngestFromUrlOptions {
14
+ export interface IStaticAssetIngestFromUrlOptions {
15
15
  helper: IStorageHelper;
16
16
  url: string;
17
17
  bucket: IBucketRef;
@@ -45,7 +45,7 @@ export interface IIngestFromUrlOptions {
45
45
  }) => string;
46
46
  }
47
47
  /** Storing an object that came from somewhere else. */
48
- export declare class AssetIngest {
48
+ export declare class StaticAssetIngestUtility {
49
49
  /**
50
50
  * Fetches an untrusted url and stores what comes back, without the bytes passing through this
51
51
  * process: the guarded body is capped and handed to `writeStream` as a stream.
@@ -57,6 +57,6 @@ export declare class AssetIngest {
57
57
  * The served content type is decided from the stored KEY, never from what the remote host
58
58
  * claimed - the same rule the asset routes apply, and for the same reason.
59
59
  */
60
- static fromUrl(opts: IIngestFromUrlOptions): Promise<IIngestFromUrlResult>;
60
+ static fromUrl(opts: IStaticAssetIngestFromUrlOptions): Promise<IStaticAssetIngestFromUrlResult>;
61
61
  }
62
- //# sourceMappingURL=ingest.d.ts.map
62
+ //# sourceMappingURL=ingest.utility.d.ts.map
@@ -7,7 +7,7 @@ const readKeyFromUrl = (opts) => {
7
7
  return folderPath ? `${folderPath}/${normalized}` : normalized;
8
8
  };
9
9
  /** Storing an object that came from somewhere else. */
10
- export class AssetIngest {
10
+ export class StaticAssetIngestUtility {
11
11
  /**
12
12
  * Fetches an untrusted url and stores what comes back, without the bytes passing through this
13
13
  * process: the guarded body is capped and handed to `writeStream` as a stream.
@@ -31,23 +31,25 @@ export class AssetIngest {
31
31
  // the same depth rule as one arriving through the upload route.
32
32
  if (!helper.isValidObjectKey({ object: { key }, maxDepth: opts.maxFolderDepth })) {
33
33
  await response.body?.cancel();
34
- throw getError({ message: `[AssetIngest.fromUrl] Invalid object key | key: ${key}` });
34
+ throw getError({
35
+ message: `[StaticAssetIngestUtility.fromUrl] Invalid object key | key: ${key}`,
36
+ });
35
37
  }
36
- // Refused BEFORE the write starts, so a body that declares its size never opens a multipart
37
- // upload at all. A body that lies or omits the header is caught mid-flight by `capStream`, and
38
- // Bun's client answers that with `AbortMultipartUpload` - measured against a recording endpoint,
39
- // not assumed - so no orphaned parts are left behind either way.
38
+ // Refused before the write starts, so a declared size never opens a multipart upload. A body
39
+ // that lies or omits it is caught by `capStream`; Bun's client aborts the upload, leaving no parts.
40
40
  const declaredLength = Number(response.headers.get('content-length') ?? 0);
41
41
  const maxBytes = policy?.maxBytes ?? UrlSafetyDefaults.MAX_BYTES;
42
42
  if (declaredLength > maxBytes) {
43
43
  await response.body?.cancel();
44
44
  throw getError({
45
45
  error: UrlSafetyErrors.URL_REFUSED,
46
- message: `[AssetIngest.fromUrl] Body exceeds the cap | declared: ${declaredLength} | max: ${maxBytes}`,
46
+ message: `[StaticAssetIngestUtility.fromUrl] Body exceeds the cap | declared: ${declaredLength} | max: ${maxBytes}`,
47
47
  });
48
48
  }
49
49
  if (!response.body) {
50
- throw getError({ message: `[AssetIngest.fromUrl] Response carried no body | url: ${url}` });
50
+ throw getError({
51
+ message: `[StaticAssetIngestUtility.fromUrl] Response carried no body | url: ${url}`,
52
+ });
51
53
  }
52
54
  const object = { key };
53
55
  const contentType = helper.getMimeType({ filename: key });
@@ -62,7 +64,7 @@ export class AssetIngest {
62
64
  const link = normalizeLinkFn({ bucket, object });
63
65
  if (!link) {
64
66
  throw getError({
65
- message: `[AssetIngest.fromUrl] normalizeLinkFn returned an empty link | key: ${key}`,
67
+ message: `[StaticAssetIngestUtility.fromUrl] normalizeLinkFn returned an empty link | key: ${key}`,
66
68
  });
67
69
  }
68
70
  return {
@@ -75,4 +77,4 @@ export class AssetIngest {
75
77
  };
76
78
  }
77
79
  }
78
- //# sourceMappingURL=ingest.js.map
80
+ //# sourceMappingURL=ingest.utility.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ingest.utility.js","sourceRoot":"","sources":["../../../../../src/components/static-asset/utilities/ingest.utility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EACL,SAAS,EACT,iBAAiB,EACjB,eAAe,GAOhB,MAAM,wBAAwB,CAAC;AA+ChC,MAAM,cAAc,GAAG,CAAC,IAAuC,EAAU,EAAE;IACzE,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;IACjC,MAAM,WAAW,GAAG,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,IAAI,QAAQ,CAAC;IAC9E,MAAM,UAAU,GAAG,WAAW,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAEhE,OAAO,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,IAAI,UAAU,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC;AACjE,CAAC,CAAC;AAEF,uDAAuD;AACvD,MAAM,OAAO,wBAAwB;IACnC;;;;;;;;;;OAUG;IACH,MAAM,CAAC,KAAK,CAAC,OAAO,CAClB,IAAsC;QAEtC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,eAAe,EAAE,GAAG,IAAI,CAAC;QAEtF,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,YAAY,CAAC,EAAE,GAAG,EAA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,CAAC;QAED,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;YACnB,MAAM,QAAQ,CAAC;gBACb,OAAO,EAAE,sEAAsE,GAAG,EAAE;aACrF,CAAC,CAAC;QACL,CAAC;QAED,MAAM,MAAM,GAAe,EAAE,GAAG,EAAE,CAAC;QACnC,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAC;QAE1D,MAAM,MAAM,CAAC,WAAW,CAAC;YACvB,MAAM;YACN,MAAM;YACN,MAAM,EAAE,SAAS,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC;YAC9D,WAAW;YACX,cAAc,EAAE,IAAI,CAAC,cAAc;SACpC,CAAC,CAAC;QAEH,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QACtD,MAAM,IAAI,GAAG,eAAe,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QAEjD,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,QAAQ,CAAC;gBACb,OAAO,EAAE,oFAAoF,GAAG,EAAE;aACnG,CAAC,CAAC;QACL,CAAC;QAED,OAAO;YACL,MAAM,EAAE;gBACN,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE;gBAC7B,MAAM,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE;gBAC7C,IAAI;aACL;YACD,IAAI;SACL,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { getError } from '@venizia/ignis-helpers/core';\nimport {\n UrlIngest,\n UrlSafetyDefaults,\n UrlSafetyErrors,\n type IBucketRef,\n type IObjectRef,\n type IFileStat,\n type IStorageHelper,\n type IUploadResult,\n type IUrlSafetyPolicy,\n} from '@venizia/ignis-helpers';\n\n/**\n * What was stored, and what the backend reports about it. The stat is returned because `getStat`\n * already ran to size the result - a caller writing its own row would otherwise pay for it twice.\n *\n * This does NOT write a meta link. The columns an application attaches to an object - a principal,\n * a variant - come from its own domain, not from the object, so the row stays the caller's.\n */\nexport interface IStaticAssetIngestFromUrlResult {\n upload: IUploadResult;\n stat: IFileStat;\n}\n\n/** Where a fetched object lands, and what it is attached to. */\nexport interface IStaticAssetIngestFromUrlOptions {\n helper: IStorageHelper;\n url: string;\n bucket: IBucketRef;\n\n /**\n * Decides the stored key.\n *\n * **Absent, the key comes from the remote url's last path segment - which on an untrusted url is\n * named by whoever supplied it.** Pass `resolveKey` whenever the url is not your own; the\n * validation below bounds what it can do, but it does not make the remote name yours.\n */\n resolveKey?: (opts: { url: URL; contentType: string }) => string;\n folderPath?: string;\n\n /** Absent leaves IGNIS's own default: https only, no private address, 3 hops, 10s, 10 MB. */\n policy?: IUrlSafetyPolicy;\n\n /**\n * Folder nesting the key may carry.\n *\n * @default BaseStorageHelper.DEFAULT_MAX_FOLDER_DEPTH\n */\n maxFolderDepth?: number;\n\n /**\n * Where the object is served from. **Required**: an absent hook used to yield an empty link, which\n * is exactly the value that satisfies a NOT NULL column and points nowhere.\n */\n normalizeLinkFn: (opts: { bucket: IBucketRef; object: IObjectRef }) => string;\n}\n\nconst readKeyFromUrl = (opts: { url: URL; folderPath?: string }): string => {\n const { url, folderPath } = opts;\n const lastSegment = url.pathname.split('/').filter(Boolean).pop() ?? 'object';\n const normalized = lastSegment.toLowerCase().replace(/ /g, '_');\n\n return folderPath ? `${folderPath}/${normalized}` : normalized;\n};\n\n/** Storing an object that came from somewhere else. */\nexport class StaticAssetIngestUtility {\n /**\n * Fetches an untrusted url and stores what comes back, without the bytes passing through this\n * process: the guarded body is capped and handed to `writeStream` as a stream.\n *\n * The url is guarded by `UrlIngest.fetchGuarded` - scheme allow-list, every resolved address\n * checked, redirects walked by hand with a per-hop re-check, and a timeout. The connection goes to the\n * address that was checked, so a DNS answer that changes afterwards is never used; see `UrlIngest.fetchGuarded`.\n *\n * The served content type is decided from the stored KEY, never from what the remote host\n * claimed - the same rule the asset routes apply, and for the same reason.\n */\n static async fromUrl(\n opts: IStaticAssetIngestFromUrlOptions,\n ): Promise<IStaticAssetIngestFromUrlResult> {\n const { helper, url, bucket, folderPath, policy, resolveKey, normalizeLinkFn } = opts;\n\n const response = await UrlIngest.fetchGuarded({ url, policy });\n const remoteType = response.headers.get('content-type')?.split(';')[0]?.trim() ?? '';\n const parsed = new URL(url);\n\n const key = resolveKey\n ? resolveKey({ url: parsed, contentType: remoteType })\n : readKeyFromUrl({ url: parsed, folderPath });\n\n // The helper's own default, not an unbounded one: an object arriving through ingest must obey\n // the same depth rule as one arriving through the upload route.\n if (!helper.isValidObjectKey({ object: { key }, maxDepth: opts.maxFolderDepth })) {\n await response.body?.cancel();\n throw getError({\n message: `[StaticAssetIngestUtility.fromUrl] Invalid object key | key: ${key}`,\n });\n }\n\n // Refused before the write starts, so a declared size never opens a multipart upload. A body\n // that lies or omits it is caught by `capStream`; Bun's client aborts the upload, leaving no parts.\n const declaredLength = Number(response.headers.get('content-length') ?? 0);\n const maxBytes = policy?.maxBytes ?? UrlSafetyDefaults.MAX_BYTES;\n\n if (declaredLength > maxBytes) {\n await response.body?.cancel();\n throw getError({\n error: UrlSafetyErrors.URL_REFUSED,\n message: `[StaticAssetIngestUtility.fromUrl] Body exceeds the cap | declared: ${declaredLength} | max: ${maxBytes}`,\n });\n }\n\n if (!response.body) {\n throw getError({\n message: `[StaticAssetIngestUtility.fromUrl] Response carried no body | url: ${url}`,\n });\n }\n\n const object: IObjectRef = { key };\n const contentType = helper.getMimeType({ filename: key });\n\n await helper.writeStream({\n bucket,\n object,\n source: UrlIngest.capStream({ source: response.body, policy }),\n contentType,\n maxFolderDepth: opts.maxFolderDepth,\n });\n\n const stat = await helper.getStat({ bucket, object });\n const link = normalizeLinkFn({ bucket, object });\n\n if (!link) {\n throw getError({\n message: `[StaticAssetIngestUtility.fromUrl] normalizeLinkFn returned an empty link | key: ${key}`,\n });\n }\n\n return {\n upload: {\n bucket: { name: bucket.name },\n object: { key, size: stat.size, contentType },\n link,\n },\n stat,\n };\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { type IStorageHelper } from '@venizia/ignis-helpers';
2
- export declare class AssetKeyScope {
2
+ export declare class StaticAssetKeyScopeUtility {
3
3
  /** `tenant-a`, `/tenant-a` and `tenant-a/` all become `tenant-a/`: without the slash, `tenant-a` would also own `tenant-ab/`. */
4
4
  static normalizePrefix(opts: {
5
5
  keyPrefix: string;
@@ -9,6 +9,25 @@ export declare class AssetKeyScope {
9
9
  keyPrefix: string;
10
10
  depth: number;
11
11
  };
12
+ /**
13
+ * The two prefixes of a direct upload, in ONE place: the policy signs `policyKeyPrefix`, and the
14
+ * commit strips `pendingPrefix` from the key it reads back, so the two have to be computed alike.
15
+ * The scope rides inside the pending key, so a commit lands inside it.
16
+ *
17
+ * A pending object must never be readable through the entry's own routes, so `pendingPrefix` is
18
+ * refused unless it is a valid key prefix of its own, disjoint from `keyPrefix`: neither starts
19
+ * with the other. Both are checked once, at boot, with the entry's name.
20
+ */
21
+ static resolveDirectUploadPrefixes(opts: {
22
+ keyPrefix: string;
23
+ pendingPrefix?: string;
24
+ helper: IStorageHelper;
25
+ scope: string;
26
+ }): {
27
+ keyPrefix: string;
28
+ pendingPrefix: string;
29
+ policyKeyPrefix: string;
30
+ };
12
31
  static isInScope(opts: {
13
32
  key: string;
14
33
  keyPrefix?: string;
@@ -27,4 +46,4 @@ export declare class AssetKeyScope {
27
46
  isOutOfScope: boolean;
28
47
  };
29
48
  }
30
- //# sourceMappingURL=key-scope.d.ts.map
49
+ //# sourceMappingURL=key-scope.utility.d.ts.map
@@ -0,0 +1,74 @@
1
+ import { StorageErrors } from '@venizia/ignis-helpers';
2
+ import { getError } from '@venizia/ignis-helpers/core';
3
+ import { StaticAssetDefaults } from '../common/index.js';
4
+ export class StaticAssetKeyScopeUtility {
5
+ /** `tenant-a`, `/tenant-a` and `tenant-a/` all become `tenant-a/`: without the slash, `tenant-a` would also own `tenant-ab/`. */
6
+ static normalizePrefix(opts) {
7
+ const { keyPrefix, helper, scope } = opts;
8
+ const trimmed = keyPrefix.replace(/^\/+|\/+$/g, '');
9
+ const segments = trimmed ? trimmed.split('/') : [];
10
+ if (segments.length === 0 || segments.some((segment) => !helper.isValidSegment({ segment }))) {
11
+ throw getError({
12
+ message: `[${scope}] keyPrefix must be one or more valid key segments | value: ${keyPrefix}`,
13
+ });
14
+ }
15
+ return { keyPrefix: `${trimmed}/`, depth: segments.length };
16
+ }
17
+ /**
18
+ * The two prefixes of a direct upload, in ONE place: the policy signs `policyKeyPrefix`, and the
19
+ * commit strips `pendingPrefix` from the key it reads back, so the two have to be computed alike.
20
+ * The scope rides inside the pending key, so a commit lands inside it.
21
+ *
22
+ * A pending object must never be readable through the entry's own routes, so `pendingPrefix` is
23
+ * refused unless it is a valid key prefix of its own, disjoint from `keyPrefix`: neither starts
24
+ * with the other. Both are checked once, at boot, with the entry's name.
25
+ */
26
+ static resolveDirectUploadPrefixes(opts) {
27
+ const { helper, scope } = opts;
28
+ const { keyPrefix } = StaticAssetKeyScopeUtility.normalizePrefix({
29
+ keyPrefix: opts.keyPrefix,
30
+ helper,
31
+ scope,
32
+ });
33
+ const pendingPrefix = opts.pendingPrefix ?? StaticAssetDefaults.PENDING_PREFIX;
34
+ const segments = pendingPrefix.slice(0, -1).split('/');
35
+ if (pendingPrefix.length < 2 ||
36
+ !pendingPrefix.endsWith('/') ||
37
+ segments.some((segment) => !helper.isValidSegment({ segment }))) {
38
+ throw getError({
39
+ message: `[${scope}] directUpload.pendingPrefix must be one or more valid key segments, each followed by a slash | value: '${pendingPrefix}'`,
40
+ });
41
+ }
42
+ if (pendingPrefix.startsWith(keyPrefix) || keyPrefix.startsWith(pendingPrefix)) {
43
+ throw getError({
44
+ message: `[${scope}] directUpload.pendingPrefix and keyPrefix must not contain one another | pendingPrefix: '${pendingPrefix}' | keyPrefix: '${keyPrefix}' | a pending object would be readable through this entry's routes`,
45
+ });
46
+ }
47
+ return { keyPrefix, pendingPrefix, policyKeyPrefix: `${pendingPrefix}${keyPrefix}` };
48
+ }
49
+ static isInScope(opts) {
50
+ return opts.keyPrefix === undefined || opts.key.startsWith(opts.keyPrefix);
51
+ }
52
+ /** A key outside the scope answers as a missing object does, so a caller learns nothing about keys it does not own. */
53
+ static assertInScope(opts) {
54
+ if (StaticAssetKeyScopeUtility.isInScope(opts)) {
55
+ return;
56
+ }
57
+ throw getError({
58
+ error: StorageErrors.OBJECT_NOT_FOUND,
59
+ message: `Object not found | key: ${opts.key}`,
60
+ });
61
+ }
62
+ /** A caller prefix wider than the scope is narrowed to it; one wholly outside it lists nothing. */
63
+ static resolveListPrefix(opts) {
64
+ const { prefix, keyPrefix } = opts;
65
+ if (keyPrefix === undefined) {
66
+ return { prefix, isOutOfScope: false };
67
+ }
68
+ if (!prefix || keyPrefix.startsWith(prefix)) {
69
+ return { prefix: keyPrefix, isOutOfScope: false };
70
+ }
71
+ return { prefix, isOutOfScope: !prefix.startsWith(keyPrefix) };
72
+ }
73
+ }
74
+ //# sourceMappingURL=key-scope.utility.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"key-scope.utility.js","sourceRoot":"","sources":["../../../../../src/components/static-asset/utilities/key-scope.utility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAuB,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAEhD,MAAM,OAAO,0BAA0B;IACrC,iIAAiI;IACjI,MAAM,CAAC,eAAe,CAAC,IAAkE;QAIvF,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;QAC1C,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC,YAAY,EA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AAC;QACpD,CAAC;QAED,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;IACjE,CAAC;CACF","sourcesContent":["import { StorageErrors, type IStorageHelper } from '@venizia/ignis-helpers';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { StaticAssetDefaults } from '../common';\n\nexport class StaticAssetKeyScopeUtility {\n /** `tenant-a`, `/tenant-a` and `tenant-a/` all become `tenant-a/`: without the slash, `tenant-a` would also own `tenant-ab/`. */\n static normalizePrefix(opts: { keyPrefix: string; helper: IStorageHelper; scope: string }): {\n keyPrefix: string;\n depth: number;\n } {\n const { keyPrefix, helper, scope } = opts;\n const trimmed = keyPrefix.replace(/^\\/+|\\/+$/g, '');\n const segments = trimmed ? trimmed.split('/') : [];\n\n if (segments.length === 0 || segments.some((segment) => !helper.isValidSegment({ segment }))) {\n throw getError({\n message: `[${scope}] keyPrefix must be one or more valid key segments | value: ${keyPrefix}`,\n });\n }\n\n return { keyPrefix: `${trimmed}/`, depth: segments.length };\n }\n\n /**\n * The two prefixes of a direct upload, in ONE place: the policy signs `policyKeyPrefix`, and the\n * commit strips `pendingPrefix` from the key it reads back, so the two have to be computed alike.\n * The scope rides inside the pending key, so a commit lands inside it.\n *\n * A pending object must never be readable through the entry's own routes, so `pendingPrefix` is\n * refused unless it is a valid key prefix of its own, disjoint from `keyPrefix`: neither starts\n * with the other. Both are checked once, at boot, with the entry's name.\n */\n static resolveDirectUploadPrefixes(opts: {\n keyPrefix: string;\n pendingPrefix?: string;\n helper: IStorageHelper;\n scope: string;\n }): { keyPrefix: string; pendingPrefix: string; policyKeyPrefix: string } {\n const { helper, scope } = opts;\n const { keyPrefix } = StaticAssetKeyScopeUtility.normalizePrefix({\n keyPrefix: opts.keyPrefix,\n helper,\n scope,\n });\n const pendingPrefix = opts.pendingPrefix ?? StaticAssetDefaults.PENDING_PREFIX;\n const segments = pendingPrefix.slice(0, -1).split('/');\n\n if (\n pendingPrefix.length < 2 ||\n !pendingPrefix.endsWith('/') ||\n segments.some((segment) => !helper.isValidSegment({ segment }))\n ) {\n throw getError({\n message: `[${scope}] directUpload.pendingPrefix must be one or more valid key segments, each followed by a slash | value: '${pendingPrefix}'`,\n });\n }\n\n if (pendingPrefix.startsWith(keyPrefix) || keyPrefix.startsWith(pendingPrefix)) {\n throw getError({\n message: `[${scope}] directUpload.pendingPrefix and keyPrefix must not contain one another | pendingPrefix: '${pendingPrefix}' | keyPrefix: '${keyPrefix}' | a pending object would be readable through this entry's routes`,\n });\n }\n\n return { keyPrefix, pendingPrefix, policyKeyPrefix: `${pendingPrefix}${keyPrefix}` };\n }\n\n static isInScope(opts: { key: string; keyPrefix?: string }): boolean {\n return opts.keyPrefix === undefined || opts.key.startsWith(opts.keyPrefix);\n }\n\n /** A key outside the scope answers as a missing object does, so a caller learns nothing about keys it does not own. */\n static assertInScope(opts: { key: string; keyPrefix?: string }): void {\n if (StaticAssetKeyScopeUtility.isInScope(opts)) {\n return;\n }\n\n throw getError({\n error: StorageErrors.OBJECT_NOT_FOUND,\n message: `Object not found | key: ${opts.key}`,\n });\n }\n\n /** A caller prefix wider than the scope is narrowed to it; one wholly outside it lists nothing. */\n static resolveListPrefix(opts: { prefix?: string; keyPrefix?: string }): {\n prefix?: string;\n isOutOfScope: boolean;\n } {\n const { prefix, keyPrefix } = opts;\n\n if (keyPrefix === undefined) {\n return { prefix, isOutOfScope: false };\n }\n\n if (!prefix || keyPrefix.startsWith(prefix)) {\n return { prefix: keyPrefix, isOutOfScope: false };\n }\n\n return { prefix, isOutOfScope: !prefix.startsWith(keyPrefix) };\n }\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import type { IBucketRef, IFileStat, IObjectRef, IStorageHelper, IUploadResult } from '@venizia/ignis-helpers';
2
- import type { AnyType } from '@venizia/ignis-helpers/common';
3
- import type { TMetaLinkConfig, TStaticAssetStorageType, TUploadQuery } from '../common/index.js';
4
- export declare class AssetMetaLink {
2
+ import type { TMetaLink, TMetaLinkCompatibleSchema } from '../models/index.js';
3
+ import type { TMetaLinkConfig, TStaticAssetStorageType, TStaticAssetUploadLabels } from '../common/index.js';
4
+ export declare class StaticAssetMetaLinkUtility {
5
5
  /** What a stat says about one stored object: the columns a refresh rewrites and a new row starts from. */
6
6
  private static buildStoredObjectFacts;
7
7
  /** The upload result of an object already in storage, so a commit or a recreate writes its row the way an upload does. */
@@ -14,20 +14,20 @@ export declare class AssetMetaLink {
14
14
  }): IUploadResult;
15
15
  /** The MetaLink row for one stored object. Every path that creates a row goes through here, so each lands exactly the row an ordinary upload does. */
16
16
  static createRow(opts: {
17
- metaLink: TMetaLinkConfig<AnyType>;
17
+ metaLink: TMetaLinkConfig<TMetaLinkCompatibleSchema>;
18
18
  helper: IStorageHelper;
19
19
  storage: TStaticAssetStorageType;
20
20
  uploadResult: IUploadResult;
21
21
  fileStat: IFileStat;
22
- query: TUploadQuery;
23
- }): Promise<AnyType>;
22
+ labels: TStaticAssetUploadLabels;
23
+ }): Promise<TMetaLink>;
24
24
  /**
25
25
  * Rewrites the stored-object facts on every row of the pair. Rows per pair are deliberately not
26
26
  * unique, and each keeps its own labels and storage type. A `createMetaLink` hook owns `link` and
27
27
  * `metadata`, so with one only the stat columns change; without one, `metadata` is merged per row.
28
28
  */
29
29
  static refreshRows(opts: {
30
- metaLink: TMetaLinkConfig<AnyType>;
30
+ metaLink: TMetaLinkConfig<TMetaLinkCompatibleSchema>;
31
31
  helper: IStorageHelper;
32
32
  bucket: IBucketRef;
33
33
  object: IObjectRef;
@@ -35,7 +35,7 @@ export declare class AssetMetaLink {
35
35
  fileStat: IFileStat;
36
36
  }): Promise<{
37
37
  count: number;
38
- data: AnyType[];
38
+ data: TMetaLink[];
39
39
  }>;
40
40
  }
41
- //# sourceMappingURL=meta-link.d.ts.map
41
+ //# sourceMappingURL=meta-link.utility.d.ts.map