@dual-os/cli 0.0.0-stage → 0.11.0-next.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 (254) hide show
  1. package/LICENSE +4 -0
  2. package/README.md +15 -2
  3. package/dist/_virtual/_rolldown/runtime.js +13 -0
  4. package/dist/auth/credentials.d.ts +17 -0
  5. package/dist/auth/credentials.d.ts.map +1 -0
  6. package/dist/auth/credentials.js +57 -0
  7. package/dist/auth/credentials.js.map +1 -0
  8. package/dist/auth/destination.d.ts +22 -0
  9. package/dist/auth/destination.d.ts.map +1 -0
  10. package/dist/auth/destination.js +49 -0
  11. package/dist/auth/destination.js.map +1 -0
  12. package/dist/auth/http.d.ts +12 -0
  13. package/dist/auth/http.d.ts.map +1 -0
  14. package/dist/auth/http.js +34 -0
  15. package/dist/auth/http.js.map +1 -0
  16. package/dist/auth/login.d.ts +22 -0
  17. package/dist/auth/login.d.ts.map +1 -0
  18. package/dist/auth/login.js +98 -0
  19. package/dist/auth/login.js.map +1 -0
  20. package/dist/auth/protocol.d.ts +26 -0
  21. package/dist/auth/protocol.d.ts.map +1 -0
  22. package/dist/auth/protocol.js +31 -0
  23. package/dist/auth/protocol.js.map +1 -0
  24. package/dist/baseline.d.ts +18 -0
  25. package/dist/baseline.d.ts.map +1 -0
  26. package/dist/baseline.js +22 -0
  27. package/dist/baseline.js.map +1 -0
  28. package/dist/bin.d.ts +1 -0
  29. package/dist/bin.js +7 -0
  30. package/dist/bin.js.map +1 -0
  31. package/dist/cli.d.ts +19 -0
  32. package/dist/cli.d.ts.map +1 -0
  33. package/dist/cli.js +492 -0
  34. package/dist/cli.js.map +1 -0
  35. package/dist/create/choices.d.ts +58 -0
  36. package/dist/create/choices.d.ts.map +1 -0
  37. package/dist/create/choices.js +121 -0
  38. package/dist/create/choices.js.map +1 -0
  39. package/dist/create/deployment.d.ts +48 -0
  40. package/dist/create/deployment.d.ts.map +1 -0
  41. package/dist/create/deployment.js +66 -0
  42. package/dist/create/deployment.js.map +1 -0
  43. package/dist/create/scaffold.d.ts +57 -0
  44. package/dist/create/scaffold.d.ts.map +1 -0
  45. package/dist/create/scaffold.js +198 -0
  46. package/dist/create/scaffold.js.map +1 -0
  47. package/dist/create/source-reference.d.ts +39 -0
  48. package/dist/create/source-reference.d.ts.map +1 -0
  49. package/dist/create/source-reference.js +185 -0
  50. package/dist/create/source-reference.js.map +1 -0
  51. package/dist/create/template.d.ts +116 -0
  52. package/dist/create/template.d.ts.map +1 -0
  53. package/dist/create/template.js +211 -0
  54. package/dist/create/template.js.map +1 -0
  55. package/dist/diagnostics.d.ts +6 -0
  56. package/dist/diagnostics.d.ts.map +1 -0
  57. package/dist/diagnostics.js +18 -0
  58. package/dist/diagnostics.js.map +1 -0
  59. package/dist/help.d.ts +16 -0
  60. package/dist/help.d.ts.map +1 -0
  61. package/dist/help.js +73 -0
  62. package/dist/help.js.map +1 -0
  63. package/dist/openapi/bundle.d.ts +18 -0
  64. package/dist/openapi/bundle.d.ts.map +1 -0
  65. package/dist/openapi/bundle.js +201 -0
  66. package/dist/openapi/bundle.js.map +1 -0
  67. package/dist/openapi/discovery.d.ts +30 -0
  68. package/dist/openapi/discovery.d.ts.map +1 -0
  69. package/dist/openapi/discovery.js +325 -0
  70. package/dist/openapi/discovery.js.map +1 -0
  71. package/dist/openapi/emit.d.ts +52 -0
  72. package/dist/openapi/emit.d.ts.map +1 -0
  73. package/dist/openapi/emit.js +596 -0
  74. package/dist/openapi/emit.js.map +1 -0
  75. package/dist/openapi/graphql.d.ts +102 -0
  76. package/dist/openapi/graphql.d.ts.map +1 -0
  77. package/dist/openapi/graphql.js +294 -0
  78. package/dist/openapi/graphql.js.map +1 -0
  79. package/dist/openapi/identity.d.ts +88 -0
  80. package/dist/openapi/identity.d.ts.map +1 -0
  81. package/dist/openapi/identity.js +98 -0
  82. package/dist/openapi/identity.js.map +1 -0
  83. package/dist/openapi/mcp.d.ts +21 -0
  84. package/dist/openapi/mcp.d.ts.map +1 -0
  85. package/dist/openapi/mcp.js +133 -0
  86. package/dist/openapi/mcp.js.map +1 -0
  87. package/dist/openapi/operations.d.ts +165 -0
  88. package/dist/openapi/operations.d.ts.map +1 -0
  89. package/dist/openapi/operations.js +361 -0
  90. package/dist/openapi/operations.js.map +1 -0
  91. package/dist/openapi/overlay.d.ts +23 -0
  92. package/dist/openapi/overlay.d.ts.map +1 -0
  93. package/dist/openapi/overlay.js +115 -0
  94. package/dist/openapi/overlay.js.map +1 -0
  95. package/dist/openapi/plugin.d.ts +83 -0
  96. package/dist/openapi/plugin.d.ts.map +1 -0
  97. package/dist/openapi/plugin.js +468 -0
  98. package/dist/openapi/plugin.js.map +1 -0
  99. package/dist/openapi/polymorphism.d.ts +21 -0
  100. package/dist/openapi/polymorphism.d.ts.map +1 -0
  101. package/dist/openapi/polymorphism.js +96 -0
  102. package/dist/openapi/polymorphism.js.map +1 -0
  103. package/dist/openapi/postman.d.ts +21 -0
  104. package/dist/openapi/postman.d.ts.map +1 -0
  105. package/dist/openapi/postman.js +286 -0
  106. package/dist/openapi/postman.js.map +1 -0
  107. package/dist/openapi/schema.d.ts +178 -0
  108. package/dist/openapi/schema.d.ts.map +1 -0
  109. package/dist/openapi/schema.js +1234 -0
  110. package/dist/openapi/schema.js.map +1 -0
  111. package/dist/openapi/select.d.ts +22 -0
  112. package/dist/openapi/select.d.ts.map +1 -0
  113. package/dist/openapi/select.js +79 -0
  114. package/dist/openapi/select.js.map +1 -0
  115. package/dist/openapi/spec.d.ts +147 -0
  116. package/dist/openapi/spec.d.ts.map +1 -0
  117. package/dist/openapi/spec.js +263 -0
  118. package/dist/openapi/spec.js.map +1 -0
  119. package/dist/openapi/swagger.d.ts +166 -0
  120. package/dist/openapi/swagger.d.ts.map +1 -0
  121. package/dist/openapi/swagger.js +298 -0
  122. package/dist/openapi/swagger.js.map +1 -0
  123. package/dist/openapi/versions.d.ts +52 -0
  124. package/dist/openapi/versions.d.ts.map +1 -0
  125. package/dist/openapi/versions.js +120 -0
  126. package/dist/openapi/versions.js.map +1 -0
  127. package/dist/plugin/archive.d.ts +27 -0
  128. package/dist/plugin/archive.d.ts.map +1 -0
  129. package/dist/plugin/archive.js +170 -0
  130. package/dist/plugin/archive.js.map +1 -0
  131. package/dist/plugin/bundle.d.ts +27 -0
  132. package/dist/plugin/bundle.d.ts.map +1 -0
  133. package/dist/plugin/bundle.js +328 -0
  134. package/dist/plugin/bundle.js.map +1 -0
  135. package/dist/plugin/init.d.ts +18 -0
  136. package/dist/plugin/init.d.ts.map +1 -0
  137. package/dist/plugin/init.js +121 -0
  138. package/dist/plugin/init.js.map +1 -0
  139. package/dist/plugin/inspection.d.ts +24 -0
  140. package/dist/plugin/inspection.d.ts.map +1 -0
  141. package/dist/plugin/inspection.js +24 -0
  142. package/dist/plugin/inspection.js.map +1 -0
  143. package/dist/plugin/package.d.ts +26 -0
  144. package/dist/plugin/package.d.ts.map +1 -0
  145. package/dist/plugin/package.js +73 -0
  146. package/dist/plugin/package.js.map +1 -0
  147. package/dist/plugin/publication.d.ts +29 -0
  148. package/dist/plugin/publication.d.ts.map +1 -0
  149. package/dist/plugin/publication.js +65 -0
  150. package/dist/plugin/publication.js.map +1 -0
  151. package/dist/plugin/validation.d.ts +15 -0
  152. package/dist/plugin/validation.d.ts.map +1 -0
  153. package/dist/plugin/validation.js +119 -0
  154. package/dist/plugin/validation.js.map +1 -0
  155. package/dist/release/archives.d.ts +33 -0
  156. package/dist/release/archives.d.ts.map +1 -0
  157. package/dist/release/archives.js +81 -0
  158. package/dist/release/archives.js.map +1 -0
  159. package/dist/release/release-manifest.d.ts +182 -0
  160. package/dist/release/release-manifest.d.ts.map +1 -0
  161. package/dist/release/release-manifest.js +79 -0
  162. package/dist/release/release-manifest.js.map +1 -0
  163. package/dist/release/releases.d.ts +36 -0
  164. package/dist/release/releases.d.ts.map +1 -0
  165. package/dist/release/releases.js +122 -0
  166. package/dist/release/releases.js.map +1 -0
  167. package/dist/skills.d.ts +35 -0
  168. package/dist/skills.d.ts.map +1 -0
  169. package/dist/skills.js +257 -0
  170. package/dist/skills.js.map +1 -0
  171. package/package.json +73 -4
  172. package/skills/dual-fde/SKILL.md +38 -0
  173. package/skills/dual-fde/references/access.md +62 -0
  174. package/skills/dual-fde/references/author-plugins.md +54 -0
  175. package/skills/dual-fde/references/cli.md +97 -0
  176. package/skills/dual-fde/references/manage-plugins.md +78 -0
  177. package/skills/dual-fde/references/migrations-deployment.md +84 -0
  178. package/skills/dual-fde/references/openapi-plugins.md +47 -0
  179. package/skills/dual-fde/references/sdk-docs.md +56 -0
  180. package/skills/dual-fde/references/upgrades.md +115 -0
  181. package/skills/dual-fde/references/working-context.md +69 -0
  182. package/src/auth/credentials.ts +84 -0
  183. package/src/auth/destination.ts +83 -0
  184. package/src/auth/http.ts +39 -0
  185. package/src/auth/login.ts +177 -0
  186. package/src/auth/protocol.ts +37 -0
  187. package/src/baseline.ts +15 -0
  188. package/src/bin.ts +4 -0
  189. package/src/cli.ts +969 -0
  190. package/src/create/choices.ts +177 -0
  191. package/src/create/deployment.ts +96 -0
  192. package/src/create/scaffold.ts +334 -0
  193. package/src/create/source-reference.ts +212 -0
  194. package/src/create/template.ts +300 -0
  195. package/src/diagnostics.ts +8 -0
  196. package/src/help.ts +142 -0
  197. package/src/openapi/bundle.ts +290 -0
  198. package/src/openapi/discovery.ts +438 -0
  199. package/src/openapi/emit.ts +1031 -0
  200. package/src/openapi/graphql.ts +375 -0
  201. package/src/openapi/identity.ts +153 -0
  202. package/src/openapi/mcp.ts +165 -0
  203. package/src/openapi/operations.ts +781 -0
  204. package/src/openapi/overlay.ts +195 -0
  205. package/src/openapi/plugin.ts +856 -0
  206. package/src/openapi/polymorphism.ts +207 -0
  207. package/src/openapi/postman.ts +403 -0
  208. package/src/openapi/schema.ts +2138 -0
  209. package/src/openapi/select.ts +113 -0
  210. package/src/openapi/spec.ts +401 -0
  211. package/src/openapi/swagger.ts +422 -0
  212. package/src/openapi/versions.ts +174 -0
  213. package/src/plugin/archive.ts +244 -0
  214. package/src/plugin/bundle.ts +572 -0
  215. package/src/plugin/init.ts +178 -0
  216. package/src/plugin/inspection.ts +19 -0
  217. package/src/plugin/package.ts +140 -0
  218. package/src/plugin/publication.ts +128 -0
  219. package/src/plugin/validation.ts +213 -0
  220. package/src/release/archives.ts +133 -0
  221. package/src/release/release-manifest.ts +79 -0
  222. package/src/release/releases.ts +210 -0
  223. package/src/skills.ts +434 -0
  224. package/templates/compose/.env.compose.example.hbs +3 -0
  225. package/templates/compose/.env.host.example.hbs +4 -0
  226. package/templates/compose/Dockerfile.hbs +12 -0
  227. package/templates/compose/OPERATIONS.md.hbs +159 -0
  228. package/templates/compose/_dockerignore +14 -0
  229. package/templates/compose/compose.external.yaml +7 -0
  230. package/templates/compose/compose.host-linux.yaml +5 -0
  231. package/templates/compose/compose.host.yaml.hbs +15 -0
  232. package/templates/compose/compose.yaml.hbs +85 -0
  233. package/templates/compose/release.env.hbs +2 -0
  234. package/templates/default/.env.example.hbs +79 -0
  235. package/templates/default/README.md.hbs +150 -0
  236. package/templates/default/_gitignore +11 -0
  237. package/templates/default/packages/customer-plugin/src/Customer.ts.hbs +17 -0
  238. package/templates/default/packages/customer-plugin/tsconfig.json +15 -0
  239. package/templates/default/packages/execution-layer/src/App.ts.hbs +7 -0
  240. package/templates/default/packages/execution-layer/src/Host.ts.hbs +31 -0
  241. package/templates/default/packages/execution-layer/src/Telemetry.ts.hbs +23 -0
  242. package/templates/default/packages/execution-layer/src/api.ts.hbs +21 -0
  243. package/templates/default/packages/execution-layer/src/bootstrap.ts +22 -0
  244. package/templates/default/packages/execution-layer/src/migrate.ts +11 -0
  245. package/templates/default/packages/execution-layer/src/registry-check.ts +29 -0
  246. package/templates/default/packages/execution-layer/src/registry-sync.ts +14 -0
  247. package/templates/default/packages/execution-layer/src/worker.ts.hbs +16 -0
  248. package/templates/default/packages/execution-layer/test/app.host-test.ts.hbs +58 -0
  249. package/templates/default/packages/execution-layer/test/app.test.ts.hbs +16 -0
  250. package/templates/default/tsconfig.json +5 -0
  251. package/templates/default/vitest.config.ts +5 -0
  252. package/templates/default/vitest.host.config.ts +6 -0
  253. package/templates/opensandbox/OPEN-SANDBOX.md +25 -0
  254. package/templates/opensandbox/docker/agent-sandbox.Dockerfile +41 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundle.js","names":["OpenApiSpec.asObject","OpenApiSpec.pointerToken","OpenApiSpec.pointerKey","OpenApiSpec.decode","OpenApiSpec.pointerTarget"],"sources":["../../src/openapi/bundle.ts"],"sourcesContent":["import {\n Array,\n Effect,\n HashMap,\n HashSet,\n Option,\n Predicate,\n Record,\n Ref,\n Schema,\n String,\n pipe,\n} from \"effect\";\nimport type { Path } from \"effect\";\n\nimport { OpenApiSpec } from \"./spec.ts\";\n\nexport class OpenApiBundleError extends Schema.TaggedError<OpenApiBundleError>()(\n \"OpenApiBundleError\",\n { message: Schema.String },\n) {}\n\nexport type Io = { path: Path.Path; read: (location: string) => Effect.Effect<string, string> };\n\ntype State = {\n documents: HashMap.HashMap<string, OpenApiSpec.JsonObject>;\n hoisted: OpenApiSpec.JsonObject;\n names: HashMap.HashMap<string, string>;\n};\n\ntype Position = { base: string; inSchema: boolean; inlining: string[]; keysAreNames: boolean };\n\ntype Target = { location: string; pointer: string };\n\nconst dataKeywords = [\"const\", \"default\", \"enum\", \"example\", \"examples\"];\n\nconst schemaMaps = [\"$defs\", \"definitions\", \"schemas\"];\n\nconst nameMaps = [\n ...schemaMaps,\n \"callbacks\",\n \"encoding\",\n \"headers\",\n \"links\",\n \"parameters\",\n \"patternProperties\",\n \"properties\",\n \"requestBodies\",\n \"responses\",\n \"securitySchemes\",\n];\n\nfunction unique(name: string, taken: HashSet.HashSet<string>, attempt = 1): string {\n const candidate = attempt === 1 ? name : `${name}${attempt}`;\n return HashSet.has(taken, candidate) ? unique(name, taken, attempt + 1) : candidate;\n}\n\nexport const bundle = Effect.fn(\"OpenApiBundle.bundle\")(function* (\n root: OpenApiSpec.JsonObject,\n location: string,\n io: Io,\n) {\n const swagger = root[\"swagger\"] !== undefined;\n const schemaPointer = swagger ? \"/definitions\" : \"/components/schemas\";\n const own = HashSet.fromIterable(\n Record.keys(\n OpenApiSpec.asObject(\n swagger ? root[\"definitions\"] : OpenApiSpec.asObject(root[\"components\"])?.[\"schemas\"],\n ) ?? {},\n ),\n );\n const state = yield* Ref.make<State>({\n documents: HashMap.empty(),\n hoisted: {},\n names: HashMap.empty(),\n });\n\n function local(name: string) {\n return `#${schemaPointer}/${OpenApiSpec.pointerToken(name)}`;\n }\n\n function join(from: string, reference: string) {\n if (URL.canParse(from)) return new URL(reference, from).href;\n if (URL.canParse(reference)) return reference;\n return io.path.resolve(io.path.dirname(from), reference);\n }\n\n function targetOf(reference: string, base: string): Target {\n const parts = pipe(reference, String.split(\"#\"));\n const file = Array.headNonEmpty(parts);\n return {\n location: String.isEmpty(file) ? base : join(base, file),\n pointer: pipe(\n Array.get(parts, 1),\n Option.getOrElse(() => \"\"),\n ),\n };\n }\n\n function nameOf(target: Target) {\n const token = pipe(target.pointer, String.split(\"/\"), Array.lastNonEmpty);\n if (String.isNonEmpty(token)) return OpenApiSpec.pointerKey(token);\n return io.path.parse(\n URL.canParse(target.location) ? new URL(target.location).pathname : target.location,\n ).name;\n }\n\n const failed = Effect.mapError((message: string) => OpenApiBundleError.make({ message }));\n\n const load = Effect.fnUntraced(function* (at: string) {\n return yield* Option.match(HashMap.get((yield* Ref.get(state)).documents, at), {\n onNone: () =>\n pipe(\n failed(io.read(at)),\n Effect.flatMap(text =>\n failed(\n Effect.mapError(OpenApiSpec.decode(text), () => `${at} is not a JSON or YAML object`),\n ),\n ),\n Effect.tap(document =>\n Ref.update(state, current => ({\n ...current,\n documents: HashMap.set(current.documents, at, document),\n })),\n ),\n ),\n onSome: Effect.succeed,\n });\n });\n\n const read = Effect.fnUntraced(function* (target: Target) {\n return yield* failed(\n Effect.fromResult(OpenApiSpec.pointerTarget(yield* load(target.location), target.pointer)),\n );\n });\n\n const mapValues = Effect.fnUntraced(function* <A>(\n record: OpenApiSpec.JsonObject,\n transform: (value: unknown, key: string) => Effect.Effect<A, OpenApiBundleError>,\n ) {\n return Record.fromEntries(\n yield* Effect.forEach(Record.toEntries(record), entry =>\n Effect.map(transform(entry[1], entry[0]), value => [entry[0], value] as const),\n ),\n );\n });\n\n const declare = Effect.fnUntraced(function* (\n target: Target,\n key: string,\n taken: HashSet.HashSet<string>,\n ): Effect.fn.Return<string, OpenApiBundleError> {\n const name = unique(nameOf(target), taken);\n yield* Ref.update(state, found => ({ ...found, names: HashMap.set(found.names, key, name) }));\n const bundled = yield* visit(yield* read(target), {\n base: target.location,\n inSchema: true,\n inlining: [],\n keysAreNames: false,\n });\n yield* Ref.update(state, found => ({\n ...found,\n hoisted: { ...found.hoisted, [name]: bundled },\n }));\n return local(name);\n });\n\n const hoist = Effect.fnUntraced(function* (\n target: Target,\n ): Effect.fn.Return<string, OpenApiBundleError> {\n if (target.location === location) return `#${target.pointer}`;\n const key = `${target.location}#${target.pointer}`;\n const current = yield* Ref.get(state);\n return yield* Option.match(HashMap.get(current.names, key), {\n onNone: () =>\n declare(\n target,\n key,\n HashSet.union(own, HashSet.fromIterable(HashMap.values(current.names))),\n ),\n onSome: name => Effect.succeed(local(name)),\n });\n });\n\n const inline = Effect.fnUntraced(function* (\n node: OpenApiSpec.JsonObject,\n target: Target,\n position: Position,\n ): Effect.fn.Return<unknown, OpenApiBundleError> {\n const key = `${target.location}#${target.pointer}`;\n if (Array.contains(position.inlining, key)) {\n return yield* OpenApiBundleError.make({ message: `reference cycle at ${key}` });\n }\n const inlined = yield* visit(yield* read(target), {\n base: target.location,\n inSchema: false,\n inlining: [...position.inlining, key],\n keysAreNames: false,\n });\n return Predicate.isObject(inlined) && !Array.isArray(inlined)\n ? { ...inlined, ...Record.remove(node, \"$ref\") }\n : inlined;\n });\n\n const mapped = Effect.fnUntraced(function* (value: unknown, position: Position) {\n if (!Predicate.isString(value)) return value;\n const reference = /[/#]|\\.(?:ya?ml|json)$/iu.test(value);\n if (position.base === location && (!reference || pipe(value, String.startsWith(\"#\")))) {\n return value;\n }\n return yield* hoist(\n targetOf(\n reference ? value : `#${schemaPointer}/${OpenApiSpec.pointerToken(value)}`,\n position.base,\n ),\n );\n });\n\n const member = Effect.fnUntraced(function* (\n key: string,\n value: unknown,\n position: Position,\n ): Effect.fn.Return<unknown, OpenApiBundleError> {\n if (\n !position.keysAreNames &&\n (pipe(key, String.startsWith(\"x-\")) || Array.contains(dataKeywords, key))\n ) {\n return value;\n }\n const child: Position = {\n ...position,\n inSchema:\n position.inSchema ||\n (!position.keysAreNames && (key === \"schema\" || Array.contains(schemaMaps, key))),\n keysAreNames: !position.keysAreNames && Array.contains(nameMaps, key),\n };\n const declared = OpenApiSpec.asObject(value);\n const mapping = OpenApiSpec.asObject(declared?.[\"mapping\"]);\n if (!position.keysAreNames && key === \"discriminator\" && mapping !== undefined) {\n return { ...declared, mapping: yield* mapValues(mapping, entry => mapped(entry, child)) };\n }\n return yield* visit(value, child);\n });\n\n const visitObject = Effect.fnUntraced(function* (\n node: OpenApiSpec.JsonObject,\n position: Position,\n ) {\n return yield* mapValues(node, (value, key) => member(key, value, position));\n });\n\n const visit = Effect.fnUntraced(function* (\n node: unknown,\n position: Position,\n ): Effect.fn.Return<unknown, OpenApiBundleError> {\n if (Array.isArray(node)) {\n return yield* Effect.forEach(node, item => visit(item, { ...position, keysAreNames: false }));\n }\n if (!Predicate.isObject(node)) return node;\n const reference = node[\"$ref\"];\n if (!Predicate.isString(reference)) return yield* visitObject(node, position);\n const target = targetOf(reference, position.base);\n if (target.location === location) return { ...node, $ref: `#${target.pointer}` };\n if (position.inSchema) return { ...node, $ref: yield* hoist(target) };\n return yield* inline(node, target, position);\n });\n\n const bundled = yield* visitObject(root, {\n base: location,\n inSchema: false,\n inlining: [],\n keysAreNames: false,\n });\n const hoisted = (yield* Ref.get(state)).hoisted;\n if (Record.isEmptyRecord(hoisted)) return bundled;\n return swagger\n ? { ...bundled, definitions: { ...OpenApiSpec.asObject(bundled[\"definitions\"]), ...hoisted } }\n : {\n ...bundled,\n components: {\n ...OpenApiSpec.asObject(bundled[\"components\"]),\n schemas: {\n ...OpenApiSpec.asObject(OpenApiSpec.asObject(bundled[\"components\"])?.[\"schemas\"]),\n ...hoisted,\n },\n },\n };\n});\n\nexport * as OpenApiBundle from \"./bundle.ts\";\n"],"mappings":";;;;;;;;;;AAiBA,IAAa,qBAAb,cAAwC,OAAO,YAAgC,CAAC,CAC9E,sBACA,EAAE,SAAS,OAAO,OAAO,CAC3B,CAAC,CAAC,CAAC;AAcH,MAAM,eAAe;CAAC;CAAS;CAAW;CAAQ;CAAW;AAAU;AAEvE,MAAM,aAAa;CAAC;CAAS;CAAe;AAAS;AAErD,MAAM,WAAW;CACf,GAAG;CACH;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,SAAS,OAAO,MAAc,OAAgC,UAAU,GAAW;CACjF,MAAM,YAAY,YAAY,IAAI,OAAO,GAAG,OAAO;CACnD,OAAO,QAAQ,IAAI,OAAO,SAAS,IAAI,OAAO,MAAM,OAAO,UAAU,CAAC,IAAI;AAC5E;AAEA,MAAa,SAAS,OAAO,GAAG,sBAAsB,CAAC,CAAC,WACtD,MACA,UACA,IACA;CACA,MAAM,UAAU,KAAK,eAAe,KAAA;CACpC,MAAM,gBAAgB,UAAU,iBAAiB;CACjD,MAAM,MAAM,QAAQ,aAClB,OAAO,KACLA,SACE,UAAU,KAAK,iBAAiBA,SAAqB,KAAK,aAAa,CAAC,GAAG,UAC7E,KAAK,CAAC,CACR,CACF;CACA,MAAM,QAAQ,OAAO,IAAI,KAAY;EACnC,WAAW,QAAQ,MAAM;EACzB,SAAS,CAAC;EACV,OAAO,QAAQ,MAAM;CACvB,CAAC;CAED,SAAS,MAAM,MAAc;EAC3B,OAAO,IAAI,cAAc,GAAGC,aAAyB,IAAI;CAC3D;CAEA,SAAS,KAAK,MA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GAAG,OAAO;CAC1C,OAAO,UACH;EAAE,GAAG;EAAS,aAAa;GAAE,GAAGA,SAAqB,QAAQ,cAAc;GAAG,GAAG;EAAQ;CAAE,IAC3F;EACE,GAAG;EACH,YAAY;GACV,GAAGA,SAAqB,QAAQ,aAAa;GAC7C,SAAS;IACP,GAAGA,SAAqBA,SAAqB,QAAQ,aAAa,CAAC,GAAG,UAAU;IAChF,GAAG;GACL;EACF;CACF;AACN,CAAC"}
@@ -0,0 +1,30 @@
1
+ import "./discovery.js";
2
+ import { Effect, Record, Schema } from "effect";
3
+ declare namespace discovery_d_exports {
4
+ export { discovery_d_exports as OpenApiDiscovery, toOpenApi };
5
+ }
6
+ export declare const toOpenApi: (input: unknown) => Effect.Effect<{
7
+ components: Record<string, Record<string, Record.ReadonlyRecord<string, unknown>> | {
8
+ oauth2: {
9
+ flows: {
10
+ authorizationCode: {
11
+ authorizationUrl: string;
12
+ scopes: Record<string, string>;
13
+ tokenUrl: string;
14
+ };
15
+ };
16
+ type: string;
17
+ };
18
+ }>;
19
+ externalDocs?: {
20
+ url: string;
21
+ };
22
+ info: Record<string, string>;
23
+ openapi: string;
24
+ paths: Record<string, Record<Lowercase<string>, Record<string, unknown>>>;
25
+ servers: {
26
+ url: string;
27
+ }[];
28
+ }, Schema.SchemaError, never>;
29
+ export { discovery_d_exports as OpenApiDiscovery };
30
+ //# sourceMappingURL=discovery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discovery.d.ts","names":[],"sources":["../../src/openapi/discovery.ts"],"mappings":";;;;;qBAiYa,YAAS,mBAAA,OAAA;;;MAWJ;QACE;UACE;UACA,QAAM;UACN;;;MAGJ;;;;IAQQ;;;;;;;;GAwBxB,OAAA"}
@@ -0,0 +1,325 @@
1
+ import { __exportAll } from "../_virtual/_rolldown/runtime.js";
2
+ import "./discovery.js";
3
+ import { Array, Boolean, Effect, Option, Predicate, Record, Schema, String, pipe } from "effect";
4
+ // src/openapi/discovery.ts
5
+ var discovery_exports = /* @__PURE__ */ __exportAll({
6
+ OpenApiDiscovery: () => discovery_exports,
7
+ toOpenApi: () => toOpenApi
8
+ });
9
+ const DiscoverySchema = Schema.Struct({
10
+ $ref: Schema.optionalKey(Schema.String),
11
+ default: Schema.optionalKey(Schema.String),
12
+ additionalProperties: Schema.optionalKey(Schema.suspend(() => DiscoverySchema)),
13
+ description: Schema.optionalKey(Schema.String),
14
+ enum: Schema.optionalKey(Schema.Array(Schema.String)),
15
+ format: Schema.optionalKey(Schema.String),
16
+ items: Schema.optionalKey(Schema.suspend(() => DiscoverySchema)),
17
+ location: Schema.optionalKey(Schema.String),
18
+ maximum: Schema.optionalKey(Schema.String),
19
+ minimum: Schema.optionalKey(Schema.String),
20
+ pattern: Schema.optionalKey(Schema.String),
21
+ properties: Schema.optionalKey(Schema.Record(Schema.String, Schema.suspend(() => DiscoverySchema))),
22
+ readOnly: Schema.optionalKey(Schema.Boolean),
23
+ repeated: Schema.optionalKey(Schema.Boolean),
24
+ required: Schema.optionalKey(Schema.Boolean),
25
+ type: Schema.optionalKey(Schema.String)
26
+ });
27
+ const formats = {
28
+ byte: "base64url",
29
+ "google-datetime": "date-time"
30
+ };
31
+ const DiscoveryMethod = Schema.Struct({
32
+ deprecated: Schema.optionalKey(Schema.Boolean),
33
+ description: Schema.optionalKey(Schema.String),
34
+ flatPath: Schema.optionalKey(Schema.String),
35
+ httpMethod: Schema.String,
36
+ id: Schema.String,
37
+ mediaUpload: Schema.optionalKey(Schema.Struct({
38
+ accept: Schema.Array(Schema.String),
39
+ maxSize: Schema.optionalKey(Schema.String),
40
+ protocols: Schema.Struct({
41
+ resumable: Schema.optionalKey(Schema.Struct({
42
+ multipart: Schema.optionalKey(Schema.Boolean),
43
+ path: Schema.String
44
+ })),
45
+ simple: Schema.optionalKey(Schema.Struct({
46
+ multipart: Schema.optionalKey(Schema.Boolean),
47
+ path: Schema.String
48
+ }))
49
+ })
50
+ })),
51
+ parameters: Schema.optionalKey(Schema.Record(Schema.String, DiscoverySchema)),
52
+ path: Schema.String,
53
+ request: Schema.optionalKey(Schema.Struct({ $ref: Schema.String })),
54
+ response: Schema.optionalKey(Schema.Struct({ $ref: Schema.String })),
55
+ supportsMediaDownload: Schema.optionalKey(Schema.Boolean)
56
+ });
57
+ const DiscoveryResource = Schema.Struct({
58
+ methods: Schema.optionalKey(Schema.Record(Schema.String, DiscoveryMethod)),
59
+ resources: Schema.optionalKey(Schema.Record(Schema.String, Schema.suspend(() => DiscoveryResource)))
60
+ });
61
+ const DiscoveryDocument = Schema.Struct({
62
+ ...DiscoveryResource.fields,
63
+ auth: Schema.optionalKey(Schema.Struct({ oauth2: Schema.Struct({ scopes: Schema.Record(Schema.String, Schema.Struct({ description: Schema.String })) }) })),
64
+ description: Schema.optionalKey(Schema.String),
65
+ documentationLink: Schema.optionalKey(Schema.String),
66
+ kind: Schema.Literal("discovery#restDescription"),
67
+ parameters: Schema.optionalKey(Schema.Record(Schema.String, DiscoverySchema)),
68
+ rootUrl: Schema.String,
69
+ schemas: Schema.optionalKey(Schema.Record(Schema.String, DiscoverySchema)),
70
+ servicePath: Schema.String,
71
+ title: Schema.String,
72
+ version: Schema.String
73
+ });
74
+ function reference(name) {
75
+ return { $ref: `#/components/schemas/${name}` };
76
+ }
77
+ function openApiSchema(schema) {
78
+ if (schema.$ref !== void 0) return reference(schema.$ref);
79
+ return Record.filter({
80
+ additionalProperties: schema.additionalProperties === void 0 ? void 0 : openApiSchema(schema.additionalProperties),
81
+ description: schema.description,
82
+ enum: schema.enum,
83
+ format: schema.format === void 0 ? void 0 : Option.getOrElse(Record.get(formats, schema.format), () => schema.format),
84
+ items: schema.items === void 0 ? void 0 : openApiSchema(schema.items),
85
+ maximum: schema.maximum === void 0 ? void 0 : Schema.decodeSync(Schema.FiniteFromString)(schema.maximum),
86
+ minimum: schema.minimum === void 0 ? void 0 : Schema.decodeSync(Schema.FiniteFromString)(schema.minimum),
87
+ pattern: schema.pattern,
88
+ properties: schema.properties === void 0 ? void 0 : Record.map(schema.properties, openApiSchema),
89
+ readOnly: schema.readOnly,
90
+ type: schema.type === "any" ? void 0 : schema.type
91
+ }, Predicate.isNotUndefined);
92
+ }
93
+ function methodsOf(resource, tags) {
94
+ return [...Array.map(Record.values(resource.methods ?? {}), (method) => ({
95
+ method,
96
+ tags
97
+ })), ...Array.flatten(Record.collect(resource.resources ?? {}, (name, child) => methodsOf(child, [Array.join([...tags, name], ".")])))];
98
+ }
99
+ function operation(document, located, path) {
100
+ const method = located.method;
101
+ const declared = {
102
+ ...Record.filter(document.parameters ?? {}, (_, name) => name === "fields"),
103
+ ...method.parameters,
104
+ ...method.supportsMediaDownload === true && method.response !== void 0 ? { alt: {
105
+ enum: ["json", "media"],
106
+ location: "query",
107
+ type: "string"
108
+ } } : {}
109
+ };
110
+ const pathParameters = pipe(path, String.matchAll(/\{([^}]+)\}/gu), Array.fromIterable, Array.map((match) => Array.get(match, 1)), Array.getSomes, Array.map((name) => Record.filter({
111
+ description: declared[name]?.description,
112
+ in: "path",
113
+ name,
114
+ required: true,
115
+ schema: {
116
+ ...openApiSchema(declared[name] ?? { type: "string" }),
117
+ ...declared[name]?.default === void 0 ? {} : { default: declared[name]?.default }
118
+ }
119
+ }, Predicate.isNotUndefined)));
120
+ const queryParameters = Record.collect(Record.filter(declared, (parameter) => parameter.location === "query"), (name, parameter) => Record.filter({
121
+ description: parameter.description,
122
+ in: "query",
123
+ name,
124
+ required: parameter.required,
125
+ schema: parameter.repeated === true ? {
126
+ items: openApiSchema(parameter),
127
+ type: "array"
128
+ } : openApiSchema(parameter)
129
+ }, Predicate.isNotUndefined));
130
+ return {
131
+ deprecated: method.deprecated,
132
+ description: method.description,
133
+ operationId: pipe(method.id, String.split("."), Array.drop(1), Array.join(".")),
134
+ parameters: [...pathParameters, ...queryParameters],
135
+ requestBody: method.request === void 0 ? void 0 : {
136
+ content: { "application/json": { schema: reference(method.request.$ref) } },
137
+ required: true
138
+ },
139
+ responses: method.response === void 0 ? Boolean.match(method.supportsMediaDownload === true, {
140
+ onFalse: () => ({ "204": { description: "No content" } }),
141
+ onTrue: () => ({ "200": {
142
+ content: { "*/*": { schema: {
143
+ format: "binary",
144
+ type: "string"
145
+ } } },
146
+ description: "The media"
147
+ } })
148
+ }) : { "200": {
149
+ content: {
150
+ "application/json": { schema: reference(method.response.$ref) },
151
+ ...method.supportsMediaDownload === true ? { "*/*": { schema: {
152
+ format: "binary",
153
+ type: "string"
154
+ } } } : {}
155
+ },
156
+ description: "Successful response"
157
+ } },
158
+ tags: located.tags,
159
+ ...method.supportsMediaDownload === true && method.response !== void 0 ? { "x-dual-google-download": true } : {}
160
+ };
161
+ }
162
+ function endpoints(document, located) {
163
+ const method = located.method;
164
+ const path = `/${String.replaceAll("{+", "{")(method.flatPath ?? method.path)}`;
165
+ const endpoint = {
166
+ httpMethod: String.toLowerCase(method.httpMethod),
167
+ operation: (canonicalPath) => Record.filter(operation(document, located, canonicalPath), Predicate.isNotUndefined),
168
+ path
169
+ };
170
+ const upload = method.mediaUpload;
171
+ const simple = upload?.protocols.simple;
172
+ if (upload === void 0 || simple === void 0) return [endpoint];
173
+ return [endpoint, {
174
+ httpMethod: endpoint.httpMethod,
175
+ operation: (canonicalPath) => {
176
+ const uploadOperation = operation(document, located, canonicalPath);
177
+ const file = {
178
+ format: "binary",
179
+ type: "string"
180
+ };
181
+ const metadata = method.request === void 0 ? { type: "object" } : reference(method.request.$ref);
182
+ const pending = {
183
+ properties: {
184
+ nextOffset: { type: "integer" },
185
+ sessionUrl: { type: "string" },
186
+ state: { enum: ["pending"] }
187
+ },
188
+ required: [
189
+ "state",
190
+ "sessionUrl",
191
+ "nextOffset"
192
+ ],
193
+ type: "object"
194
+ };
195
+ const session = {
196
+ sessionUrl: { type: "string" },
197
+ totalBytes: { type: "integer" }
198
+ };
199
+ const variants = [
200
+ {
201
+ properties: {
202
+ media: file,
203
+ mode: { enum: ["media"] }
204
+ },
205
+ required: ["mode", "media"],
206
+ type: "object"
207
+ },
208
+ ...simple.multipart === true ? [{
209
+ properties: {
210
+ media: file,
211
+ metadata,
212
+ mode: { enum: ["multipart"] }
213
+ },
214
+ required: [
215
+ "mode",
216
+ "metadata",
217
+ "media"
218
+ ],
219
+ type: "object"
220
+ }] : [],
221
+ ...upload.protocols.resumable === void 0 ? [] : [
222
+ {
223
+ properties: {
224
+ contentType: { type: "string" },
225
+ metadata,
226
+ mode: { enum: ["start"] },
227
+ totalBytes: { type: "integer" }
228
+ },
229
+ required: [
230
+ "mode",
231
+ "contentType",
232
+ "totalBytes"
233
+ ],
234
+ type: "object"
235
+ },
236
+ {
237
+ properties: {
238
+ media: file,
239
+ mode: { enum: ["chunk"] },
240
+ ...session,
241
+ offset: { type: "integer" }
242
+ },
243
+ required: [
244
+ "mode",
245
+ "sessionUrl",
246
+ "offset",
247
+ "totalBytes",
248
+ "media"
249
+ ],
250
+ type: "object"
251
+ },
252
+ {
253
+ properties: {
254
+ mode: { enum: ["status"] },
255
+ ...session
256
+ },
257
+ required: [
258
+ "mode",
259
+ "sessionUrl",
260
+ "totalBytes"
261
+ ],
262
+ type: "object"
263
+ }
264
+ ]
265
+ ];
266
+ return Record.filter({
267
+ ...uploadOperation,
268
+ operationId: `${uploadOperation.operationId}.upload`,
269
+ parameters: uploadOperation.parameters,
270
+ requestBody: {
271
+ content: { "application/json": { schema: { oneOf: variants } } },
272
+ required: true
273
+ },
274
+ responses: { "200": {
275
+ content: { "application/json": { schema: { oneOf: [pending, {
276
+ properties: {
277
+ resource: method.response === void 0 ? { type: "object" } : reference(method.response.$ref),
278
+ state: { enum: ["complete"] }
279
+ },
280
+ required: ["state", "resource"],
281
+ type: "object"
282
+ }] } } },
283
+ description: "The completed resource or resumable session progress"
284
+ } },
285
+ servers: [{ url: String.replace(/\/$/u, "")(document.rootUrl) }],
286
+ "x-dual-google-upload": {
287
+ ...upload.protocols.resumable === void 0 ? {} : { resumableUrl: `${String.replace(/\/$/u, "")(document.rootUrl)}${String.replaceAll("{+", "{")(upload.protocols.resumable.path)}` },
288
+ ...upload.maxSize === void 0 ? {} : { maxSize: upload.maxSize }
289
+ }
290
+ }, Predicate.isNotUndefined);
291
+ },
292
+ path: String.replaceAll("{+", "{")(simple.path)
293
+ }];
294
+ }
295
+ const toOpenApi = Effect.fn("OpenApiDiscovery.toOpenApi")(function* (input) {
296
+ const document = yield* Schema.decodeUnknownEffect(DiscoveryDocument)(input);
297
+ return {
298
+ components: Record.filter({
299
+ schemas: Record.map(document.schemas ?? {}, openApiSchema),
300
+ securitySchemes: document.auth === void 0 ? void 0 : { oauth2: {
301
+ flows: { authorizationCode: {
302
+ authorizationUrl: "https://accounts.google.com/o/oauth2/v2/auth",
303
+ scopes: Record.map(document.auth.oauth2.scopes, (scope) => scope.description),
304
+ tokenUrl: "https://oauth2.googleapis.com/token"
305
+ } },
306
+ type: "oauth2"
307
+ } }
308
+ }, Predicate.isNotUndefined),
309
+ ...document.documentationLink === void 0 ? {} : { externalDocs: { url: document.documentationLink } },
310
+ info: Record.filter({
311
+ description: document.description,
312
+ title: document.title,
313
+ version: document.version
314
+ }, Predicate.isNotUndefined),
315
+ openapi: "3.0.3",
316
+ paths: pipe(methodsOf(document, []), Array.flatMap((located) => endpoints(document, located)), Array.groupBy((endpoint) => String.replaceAll(/\{[^}]+\}/gu, "{}")(endpoint.path)), Record.values, Record.fromIterableWith((group) => {
317
+ const path = Array.headNonEmpty(group).path;
318
+ return [path, Record.fromIterableWith(group, (endpoint) => [endpoint.httpMethod, endpoint.operation(path)])];
319
+ })),
320
+ servers: [{ url: String.replace(/\/$/u, "")(`${document.rootUrl}${document.servicePath}`) }]
321
+ };
322
+ });
323
+ export { discovery_exports as OpenApiDiscovery, toOpenApi };
324
+
325
+ //# sourceMappingURL=discovery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discovery.js","names":[],"sources":["../../src/openapi/discovery.ts"],"sourcesContent":["import { Array, Boolean, Effect, Option, Predicate, Record, Schema, String, pipe } from \"effect\";\n\ntype DiscoverySchema = {\n readonly $ref?: string;\n readonly default?: string;\n readonly additionalProperties?: DiscoverySchema;\n readonly description?: string;\n readonly enum?: readonly string[];\n readonly format?: string;\n readonly items?: DiscoverySchema;\n readonly location?: string;\n readonly maximum?: string;\n readonly minimum?: string;\n readonly pattern?: string;\n readonly properties?: Record.ReadonlyRecord<string, DiscoverySchema>;\n readonly readOnly?: boolean;\n readonly repeated?: boolean;\n readonly required?: boolean;\n readonly type?: string;\n};\nconst DiscoverySchema = Schema.Struct({\n $ref: Schema.optionalKey(Schema.String),\n default: Schema.optionalKey(Schema.String),\n additionalProperties: Schema.optionalKey(\n Schema.suspend((): Schema.Codec<DiscoverySchema> => DiscoverySchema),\n ),\n description: Schema.optionalKey(Schema.String),\n enum: Schema.optionalKey(Schema.Array(Schema.String)),\n format: Schema.optionalKey(Schema.String),\n items: Schema.optionalKey(Schema.suspend((): Schema.Codec<DiscoverySchema> => DiscoverySchema)),\n location: Schema.optionalKey(Schema.String),\n maximum: Schema.optionalKey(Schema.String),\n minimum: Schema.optionalKey(Schema.String),\n pattern: Schema.optionalKey(Schema.String),\n properties: Schema.optionalKey(\n Schema.Record(\n Schema.String,\n Schema.suspend((): Schema.Codec<DiscoverySchema> => DiscoverySchema),\n ),\n ),\n readOnly: Schema.optionalKey(Schema.Boolean),\n repeated: Schema.optionalKey(Schema.Boolean),\n required: Schema.optionalKey(Schema.Boolean),\n type: Schema.optionalKey(Schema.String),\n});\n\nconst formats: Record.ReadonlyRecord<string, string> = {\n byte: \"base64url\",\n \"google-datetime\": \"date-time\",\n};\n\ntype DiscoveryMethod = typeof DiscoveryMethod.Type;\nconst DiscoveryMethod = Schema.Struct({\n deprecated: Schema.optionalKey(Schema.Boolean),\n description: Schema.optionalKey(Schema.String),\n flatPath: Schema.optionalKey(Schema.String),\n httpMethod: Schema.String,\n id: Schema.String,\n mediaUpload: Schema.optionalKey(\n Schema.Struct({\n accept: Schema.Array(Schema.String),\n maxSize: Schema.optionalKey(Schema.String),\n protocols: Schema.Struct({\n resumable: Schema.optionalKey(\n Schema.Struct({ multipart: Schema.optionalKey(Schema.Boolean), path: Schema.String }),\n ),\n simple: Schema.optionalKey(\n Schema.Struct({ multipart: Schema.optionalKey(Schema.Boolean), path: Schema.String }),\n ),\n }),\n }),\n ),\n parameters: Schema.optionalKey(Schema.Record(Schema.String, DiscoverySchema)),\n path: Schema.String,\n request: Schema.optionalKey(Schema.Struct({ $ref: Schema.String })),\n response: Schema.optionalKey(Schema.Struct({ $ref: Schema.String })),\n supportsMediaDownload: Schema.optionalKey(Schema.Boolean),\n});\n\ntype DiscoveryResource = {\n readonly methods?: Record.ReadonlyRecord<string, DiscoveryMethod>;\n readonly resources?: Record.ReadonlyRecord<string, DiscoveryResource>;\n};\nconst DiscoveryResource = Schema.Struct({\n methods: Schema.optionalKey(Schema.Record(Schema.String, DiscoveryMethod)),\n resources: Schema.optionalKey(\n Schema.Record(\n Schema.String,\n Schema.suspend((): Schema.Codec<DiscoveryResource> => DiscoveryResource),\n ),\n ),\n});\n\ntype DiscoveryDocument = typeof DiscoveryDocument.Type;\nconst DiscoveryDocument = Schema.Struct({\n ...DiscoveryResource.fields,\n auth: Schema.optionalKey(\n Schema.Struct({\n oauth2: Schema.Struct({\n scopes: Schema.Record(Schema.String, Schema.Struct({ description: Schema.String })),\n }),\n }),\n ),\n description: Schema.optionalKey(Schema.String),\n documentationLink: Schema.optionalKey(Schema.String),\n kind: Schema.Literal(\"discovery#restDescription\"),\n parameters: Schema.optionalKey(Schema.Record(Schema.String, DiscoverySchema)),\n rootUrl: Schema.String,\n schemas: Schema.optionalKey(Schema.Record(Schema.String, DiscoverySchema)),\n servicePath: Schema.String,\n title: Schema.String,\n version: Schema.String,\n});\n\ntype Located = { method: DiscoveryMethod; tags: string[] };\n\nfunction reference(name: string) {\n return { $ref: `#/components/schemas/${name}` };\n}\n\nfunction openApiSchema(schema: DiscoverySchema): Record.ReadonlyRecord<string, unknown> {\n if (schema.$ref !== undefined) return reference(schema.$ref);\n return Record.filter(\n {\n additionalProperties:\n schema.additionalProperties === undefined\n ? undefined\n : openApiSchema(schema.additionalProperties),\n description: schema.description,\n enum: schema.enum,\n format:\n schema.format === undefined\n ? undefined\n : Option.getOrElse(Record.get(formats, schema.format), () => schema.format),\n items: schema.items === undefined ? undefined : openApiSchema(schema.items),\n maximum:\n schema.maximum === undefined\n ? undefined\n : Schema.decodeSync(Schema.FiniteFromString)(schema.maximum),\n minimum:\n schema.minimum === undefined\n ? undefined\n : Schema.decodeSync(Schema.FiniteFromString)(schema.minimum),\n pattern: schema.pattern,\n properties:\n schema.properties === undefined ? undefined : Record.map(schema.properties, openApiSchema),\n readOnly: schema.readOnly,\n type: schema.type === \"any\" ? undefined : schema.type,\n },\n Predicate.isNotUndefined,\n );\n}\n\nfunction methodsOf(resource: DiscoveryResource, tags: string[]): Located[] {\n return [\n ...Array.map(Record.values(resource.methods ?? {}), method => ({ method, tags })),\n ...Array.flatten(\n Record.collect(resource.resources ?? {}, (name, child) =>\n methodsOf(child, [Array.join([...tags, name], \".\")]),\n ),\n ),\n ];\n}\n\nfunction operation(document: DiscoveryDocument, located: Located, path: string) {\n const method = located.method;\n const declared: Record.ReadonlyRecord<string, DiscoverySchema> = {\n ...Record.filter(document.parameters ?? {}, (_, name) => name === \"fields\"),\n ...method.parameters,\n ...(method.supportsMediaDownload === true && method.response !== undefined\n ? { alt: { enum: [\"json\", \"media\"], location: \"query\", type: \"string\" } }\n : {}),\n };\n const pathParameters = pipe(\n path,\n String.matchAll(/\\{([^}]+)\\}/gu),\n Array.fromIterable,\n Array.map(match => Array.get(match, 1)),\n Array.getSomes,\n Array.map(name =>\n Record.filter(\n {\n description: declared[name]?.description,\n in: \"path\",\n name,\n required: true,\n schema: {\n ...openApiSchema(declared[name] ?? { type: \"string\" }),\n ...(declared[name]?.default === undefined ? {} : { default: declared[name]?.default }),\n },\n },\n Predicate.isNotUndefined,\n ),\n ),\n );\n const queryParameters = Record.collect(\n Record.filter(declared, parameter => parameter.location === \"query\"),\n (name, parameter) =>\n Record.filter(\n {\n description: parameter.description,\n in: \"query\",\n name,\n required: parameter.required,\n schema:\n parameter.repeated === true\n ? { items: openApiSchema(parameter), type: \"array\" }\n : openApiSchema(parameter),\n },\n Predicate.isNotUndefined,\n ),\n );\n return {\n deprecated: method.deprecated,\n description: method.description,\n operationId: pipe(method.id, String.split(\".\"), Array.drop(1), Array.join(\".\")),\n parameters: [...pathParameters, ...queryParameters],\n requestBody:\n method.request === undefined\n ? undefined\n : {\n content: { \"application/json\": { schema: reference(method.request.$ref) } },\n required: true,\n },\n responses:\n method.response === undefined\n ? Boolean.match(method.supportsMediaDownload === true, {\n onFalse: () => ({ \"204\": { description: \"No content\" } }),\n onTrue: () => ({\n \"200\": {\n content: { \"*/*\": { schema: { format: \"binary\", type: \"string\" } } },\n description: \"The media\",\n },\n }),\n })\n : {\n \"200\": {\n content: {\n \"application/json\": { schema: reference(method.response.$ref) },\n ...(method.supportsMediaDownload === true\n ? { \"*/*\": { schema: { format: \"binary\", type: \"string\" } } }\n : {}),\n },\n description: \"Successful response\",\n },\n },\n tags: located.tags,\n ...(method.supportsMediaDownload === true && method.response !== undefined\n ? { \"x-dual-google-download\": true }\n : {}),\n };\n}\n\nfunction endpoints(document: DiscoveryDocument, located: Located) {\n const method = located.method;\n const path = `/${String.replaceAll(\"{+\", \"{\")(method.flatPath ?? method.path)}`;\n const endpoint = {\n httpMethod: String.toLowerCase(method.httpMethod),\n operation: (canonicalPath: string) =>\n Record.filter<string, unknown>(\n operation(document, located, canonicalPath),\n Predicate.isNotUndefined,\n ),\n path,\n };\n\n const upload = method.mediaUpload;\n const simple = upload?.protocols.simple;\n if (upload === undefined || simple === undefined) return [endpoint];\n return [\n endpoint,\n {\n httpMethod: endpoint.httpMethod,\n operation: (canonicalPath: string) => {\n const uploadOperation = operation(document, located, canonicalPath);\n const file = { format: \"binary\", type: \"string\" };\n const metadata =\n method.request === undefined ? { type: \"object\" } : reference(method.request.$ref);\n const pending = {\n properties: {\n nextOffset: { type: \"integer\" },\n sessionUrl: { type: \"string\" },\n state: { enum: [\"pending\"] },\n },\n required: [\"state\", \"sessionUrl\", \"nextOffset\"],\n type: \"object\",\n };\n const session = { sessionUrl: { type: \"string\" }, totalBytes: { type: \"integer\" } };\n const variants = [\n {\n properties: { media: file, mode: { enum: [\"media\"] } },\n required: [\"mode\", \"media\"],\n type: \"object\",\n },\n ...(simple.multipart === true\n ? [\n {\n properties: { media: file, metadata, mode: { enum: [\"multipart\"] } },\n required: [\"mode\", \"metadata\", \"media\"],\n type: \"object\",\n },\n ]\n : []),\n ...(upload.protocols.resumable === undefined\n ? []\n : [\n {\n properties: {\n contentType: { type: \"string\" },\n metadata,\n mode: { enum: [\"start\"] },\n totalBytes: { type: \"integer\" },\n },\n required: [\"mode\", \"contentType\", \"totalBytes\"],\n type: \"object\",\n },\n {\n properties: {\n media: file,\n mode: { enum: [\"chunk\"] },\n ...session,\n offset: { type: \"integer\" },\n },\n required: [\"mode\", \"sessionUrl\", \"offset\", \"totalBytes\", \"media\"],\n type: \"object\",\n },\n {\n properties: { mode: { enum: [\"status\"] }, ...session },\n required: [\"mode\", \"sessionUrl\", \"totalBytes\"],\n type: \"object\",\n },\n ]),\n ];\n return Record.filter<string, unknown>(\n {\n ...uploadOperation,\n operationId: `${uploadOperation.operationId}.upload`,\n parameters: uploadOperation.parameters,\n requestBody: {\n content: { \"application/json\": { schema: { oneOf: variants } } },\n required: true,\n },\n responses: {\n \"200\": {\n content: {\n \"application/json\": {\n schema: {\n oneOf: [\n pending,\n {\n properties: {\n resource:\n method.response === undefined\n ? { type: \"object\" }\n : reference(method.response.$ref),\n state: { enum: [\"complete\"] },\n },\n required: [\"state\", \"resource\"],\n type: \"object\",\n },\n ],\n },\n },\n },\n description: \"The completed resource or resumable session progress\",\n },\n },\n servers: [{ url: String.replace(/\\/$/u, \"\")(document.rootUrl) }],\n \"x-dual-google-upload\": {\n ...(upload.protocols.resumable === undefined\n ? {}\n : {\n resumableUrl: `${String.replace(/\\/$/u, \"\")(document.rootUrl)}${String.replaceAll(\"{+\", \"{\")(upload.protocols.resumable.path)}`,\n }),\n ...(upload.maxSize === undefined ? {} : { maxSize: upload.maxSize }),\n },\n },\n Predicate.isNotUndefined,\n );\n },\n path: String.replaceAll(\"{+\", \"{\")(simple.path),\n },\n ];\n}\n\nexport const toOpenApi = Effect.fn(\"OpenApiDiscovery.toOpenApi\")(function* (input: unknown) {\n const document = yield* Schema.decodeUnknownEffect(DiscoveryDocument)(input);\n return {\n components: Record.filter(\n {\n schemas: Record.map(document.schemas ?? {}, openApiSchema),\n securitySchemes:\n document.auth === undefined\n ? undefined\n : {\n oauth2: {\n flows: {\n authorizationCode: {\n authorizationUrl: \"https://accounts.google.com/o/oauth2/v2/auth\",\n scopes: Record.map(document.auth.oauth2.scopes, scope => scope.description),\n tokenUrl: \"https://oauth2.googleapis.com/token\",\n },\n },\n type: \"oauth2\",\n },\n },\n },\n Predicate.isNotUndefined,\n ),\n ...(document.documentationLink === undefined\n ? {}\n : { externalDocs: { url: document.documentationLink } }),\n info: Record.filter(\n { description: document.description, title: document.title, version: document.version },\n Predicate.isNotUndefined,\n ),\n openapi: \"3.0.3\",\n paths: pipe(\n methodsOf(document, []),\n Array.flatMap(located => endpoints(document, located)),\n Array.groupBy(endpoint => String.replaceAll(/\\{[^}]+\\}/gu, \"{}\")(endpoint.path)),\n Record.values,\n Record.fromIterableWith(group => {\n const path = Array.headNonEmpty(group).path;\n return [\n path,\n Record.fromIterableWith(group, endpoint => [\n endpoint.httpMethod,\n endpoint.operation(path),\n ]),\n ];\n }),\n ),\n servers: [{ url: String.replace(/\\/$/u, \"\")(`${document.rootUrl}${document.servicePath}`) }],\n };\n});\n\nexport * as OpenApiDiscovery from \"./discovery.ts\";\n"],"mappings":";;;;;;;;AAoBA,MAAM,kBAAkB,OAAO,OAAO;CACpC,MAAM,OAAO,YAAY,OAAO,MAAM;CACtC,SAAS,OAAO,YAAY,OAAO,MAAM;CACzC,sBAAs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AAkB,EAAE;EACxD,MAAM,OAAO,OACX;GAAE,aAAa,SAAS;GAAa,OAAO,SAAS;GAAO,SAAS,SAAS;EAAQ,GACtF,UAAU,cACZ;EACA,SAAS;EACT,OAAO,KACL,UAAU,UAAU,CAAC,CAAC,GACtB,MAAM,SAAQ,YAAW,UAAU,UAAU,OAAO,CAAC,GACrD,MAAM,SAAQ,aAAY,OAAO,WAAW,eAAe,IAAI,CAAC,CAAC,SAAS,IAAI,CAAC,GAC/E,OAAO,QACP,OAAO,kBAAiB,UAAS;GAC/B,MAAM,OAAO,MAAM,aAAa,KAAK,CAAC,CAAC;GACvC,OAAO,CACL,MACA,OAAO,iBAAiB,QAAO,aAAY,CACzC,SAAS,YACT,SAAS,UAAU,IAAI,CACzB,CAAC,CACH;EACF,CAAC,CACH;EACA,SAAS,CAAC,EAAE,KAAK,OAAO,QAAQ,QAAQ,EAAE,CAAC,CAAC,GAAG,SAAS,UAAU,SAAS,aAAa,EAAE,CAAC;CAC7F;AACF,CAAC"}
@@ -0,0 +1,52 @@
1
+ import { SecurityScheme } from "./spec.js";
2
+ import { Contract, Declaration } from "./schema.js";
3
+ import "./emit.js";
4
+ import { Option, Record, Schema } from "effect";
5
+ declare namespace emit_d_exports {
6
+ export { emit_d_exports as OpenApiEmit, Target, authSource, exportName, httpSource, licenseSource, operationsSource, packageJsonSource, pluginJsonSource, pluginSource, triggersSource, tsconfigSource, viteConfigSource };
7
+ }
8
+ export type Target = typeof Target.Type;
9
+ export declare const Target: Schema.Literals<readonly ["internal", "customer"]>;
10
+ interface Naming {
11
+ readonly target: Target;
12
+ readonly pluginId: string;
13
+ readonly packageScope: string;
14
+ }
15
+ /** The module export of an action's contract and call, `group_action`, in each version file. */
16
+ export declare function exportName(id: string): string;
17
+ /** A version file: the schemas and calls of the actions that changed in that version, never edited afterwards. */
18
+ export declare function operationsSource(declarations: readonly Declaration[], actions: readonly {
19
+ readonly name: string;
20
+ readonly contract: Contract;
21
+ }[]): string;
22
+ interface Provider {
23
+ readonly name: string;
24
+ readonly metadata: Record.ReadonlyRecord<string, unknown>;
25
+ readonly groups: readonly string[];
26
+ }
27
+ interface PluginAction {
28
+ readonly key: string;
29
+ readonly group: string;
30
+ readonly id: string;
31
+ readonly name: string;
32
+ readonly description: Option.Option<string>;
33
+ }
34
+ /** Current contracts and fluent implementations for one plugin. */
35
+ export declare function pluginSource(options: {
36
+ readonly pluginId: string;
37
+ readonly metadata: Record.ReadonlyRecord<string, unknown>;
38
+ readonly provider: Provider;
39
+ readonly actions: readonly PluginAction[];
40
+ readonly sandboxAccess: boolean;
41
+ }): string;
42
+ /** The package's binding of the SDK's HTTP runtime to its auth methods. */
43
+ export declare const httpSource = "// Generated by dual openapi-plugin; rerun it instead of editing.\nimport { Http } from \"@dual-os/sdk\";\nimport type { Action } from \"@dual-os/sdk\";\n\nimport * as Auth from \"../auth.ts\";\n\nexport {\n Base64FromFile,\n Base64UrlFromFile,\n DataUriFromFile,\n DateTimeFromRfc2822,\n DateTimeFromUnixSeconds,\n File,\n FileFromBase64,\n FileFromBase64Url,\n FileFromDataUri,\n Rfc2822FromDateTime,\n UnixSecondsFromDateTime,\n continuation,\n decoded,\n form,\n literal,\n params,\n path,\n preauthenticated,\n segments,\n} from \"@dual-os/sdk/Http\";\n\nexport type Handler<Input, Output> = Http.Handler<typeof Auth.authMethods, Input, Output>;\n\nexport interface Context extends Action.HandlerContext<typeof Auth.authMethods> {}\n\nexport const { endpoint, execute, googleUpload, graphql, mcp, variants } = Http.make<\n typeof Auth.authMethods,\n Context\n>(Auth);\n\nexport * as Http from \"./http.ts\";\n";
44
+ export declare const triggersSource = "// Written once by dual openapi-plugin; edit freely. Delete it to regenerate.\n\nexport const triggers = [] as const;\nexport const handlers = {};\n";
45
+ export declare function authSource(schemes: readonly SecurityScheme[]): string;
46
+ export declare function packageJsonSource(naming: Naming, sdkRange: string): string;
47
+ export declare function pluginJsonSource(naming: Naming, openapi: Record.ReadonlyRecord<string, unknown>): string;
48
+ export declare function tsconfigSource(): string;
49
+ export declare function viteConfigSource(target: Target): string;
50
+ export declare const licenseSource = "All rights reserved.\n\nThis package is proprietary and is not licensed for public use or redistribution.\nUse and distribution require permission from the rights holder under a separate agreement.\n";
51
+ export { emit_d_exports as OpenApiEmit };
52
+ //# sourceMappingURL=emit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emit.d.ts","names":["OpenApiSchema.Declaration","OpenApiSchema.Contract","OpenApiSpec.SecurityScheme"],"sources":["../../src/openapi/emit.ts"],"mappings":";;;;;;;YAsBY,gBAAgB,OAAO;qBACtB,QAAM,OAAA;UAET;WACC,QAAQ;WACR;WACA;;;wBAsUK,WAAW;;wBAmMX,iBACd,uBAAuBA,eACvB;WAA6B;WAAuB,UAAUC;;UAmCtD;WACC;WACA,UAAU,OAAO;WACjB;;UAGD;WACC;WACA;WACA;WACA;WACA,aAAa,OAAO;;;wBAgBf,aAAa;WAClB;WACA,UAAU,OAAO;WACjB,UAAU;WACV,kBAAkB;WAClB;;;qBA6EE;qBAwCA;wBAyFG,WAAW,kBAAkBC;wBAwG7B,kBAAkB,QAAQ,QAAQ;wBAwClC,iBAAiB,QAAQ,QAAQ,SAAS,OAAO;wBAYjD;wBAiBA,iBAAiB,QAAQ;qBA2B5B"}