@orizm/cli 2.2.6 → 3.0.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.
- package/README.md +111 -4
- package/dist/array-update-CMFUoQEe.mjs +41 -0
- package/dist/array-update-CMFUoQEe.mjs.map +1 -0
- package/dist/array-update-Dch4e9tI.cjs +58 -0
- package/dist/array-update-Dch4e9tI.cjs.map +1 -0
- package/dist/auth-BGW072BP.mjs +18 -0
- package/dist/auth-BGW072BP.mjs.map +1 -0
- package/dist/auth-CNbONZuf.cjs +18 -0
- package/dist/auth-CNbONZuf.cjs.map +1 -0
- package/dist/bucket-6d3VNt1D.mjs +17 -0
- package/dist/bucket-6d3VNt1D.mjs.map +1 -0
- package/dist/bucket-DjbHz9_A.cjs +17 -0
- package/dist/bucket-DjbHz9_A.cjs.map +1 -0
- package/dist/cli/main.cjs +231 -0
- package/dist/cli/main.cjs.map +1 -0
- package/dist/cli/main.d.cts +1 -0
- package/dist/cli/main.d.mts +1 -0
- package/dist/cli/main.mjs +196 -0
- package/dist/cli/main.mjs.map +1 -0
- package/dist/cms-BJnovGYT.mjs +172 -0
- package/dist/cms-BJnovGYT.mjs.map +1 -0
- package/dist/cms-Cnx-lDGu.cjs +172 -0
- package/dist/cms-Cnx-lDGu.cjs.map +1 -0
- package/dist/codegen-BF5b-u46.cjs +17 -0
- package/dist/codegen-BF5b-u46.cjs.map +1 -0
- package/dist/codegen-DZOB4ttR.mjs +17 -0
- package/dist/codegen-DZOB4ttR.mjs.map +1 -0
- package/dist/config/index.cjs +49 -96
- package/dist/config/index.cjs.map +1 -1
- package/dist/config/index.d.cts +1 -53
- package/dist/config/{index.d.ts → index.d.mts} +29 -27
- package/dist/config/index.d.mts.map +1 -0
- package/dist/config/index.mjs +59 -0
- package/dist/config/index.mjs.map +1 -0
- package/dist/config-loader-BEgS869e.mjs +65 -0
- package/dist/config-loader-BEgS869e.mjs.map +1 -0
- package/dist/config-loader-D8x32gEU.cjs +78 -0
- package/dist/config-loader-D8x32gEU.cjs.map +1 -0
- package/dist/confirm-delete-B9o73U7B.cjs +19 -0
- package/dist/confirm-delete-B9o73U7B.cjs.map +1 -0
- package/dist/confirm-delete-CsWkW69-.mjs +14 -0
- package/dist/confirm-delete-CsWkW69-.mjs.map +1 -0
- package/dist/consumer-BBsH8b1j.cjs +18 -0
- package/dist/consumer-BBsH8b1j.cjs.map +1 -0
- package/dist/consumer-DqyRfpsl.mjs +18 -0
- package/dist/consumer-DqyRfpsl.mjs.map +1 -0
- package/dist/consumer-OF6Z_eTP.cjs +95 -0
- package/dist/consumer-OF6Z_eTP.cjs.map +1 -0
- package/dist/consumer-pU2HyiyA.mjs +95 -0
- package/dist/consumer-pU2HyiyA.mjs.map +1 -0
- package/dist/content-BsoRmjis.mjs +20 -0
- package/dist/content-BsoRmjis.mjs.map +1 -0
- package/dist/content-Y-2Y0cyn.cjs +20 -0
- package/dist/content-Y-2Y0cyn.cjs.map +1 -0
- package/dist/create--1NYduI_.cjs +58 -0
- package/dist/create--1NYduI_.cjs.map +1 -0
- package/dist/create-B-PAOor6.mjs +66 -0
- package/dist/create-B-PAOor6.mjs.map +1 -0
- package/dist/create-BNYWcyuQ.cjs +66 -0
- package/dist/create-BNYWcyuQ.cjs.map +1 -0
- package/dist/create-B_gsZCL-.cjs +54 -0
- package/dist/create-B_gsZCL-.cjs.map +1 -0
- package/dist/create-BqlxdhcR.mjs +81 -0
- package/dist/create-BqlxdhcR.mjs.map +1 -0
- package/dist/create-CC814ixh.mjs +66 -0
- package/dist/create-CC814ixh.mjs.map +1 -0
- package/dist/create-CkFBiEDH.mjs +58 -0
- package/dist/create-CkFBiEDH.mjs.map +1 -0
- package/dist/create-CykRHseR.cjs +81 -0
- package/dist/create-CykRHseR.cjs.map +1 -0
- package/dist/create-RLyp_dl6.mjs +54 -0
- package/dist/create-RLyp_dl6.mjs.map +1 -0
- package/dist/create-Z-z3LXNW.cjs +66 -0
- package/dist/create-Z-z3LXNW.cjs.map +1 -0
- package/dist/delete-8yZ3j0vX.cjs +59 -0
- package/dist/delete-8yZ3j0vX.cjs.map +1 -0
- package/dist/delete-BOUObrDw.mjs +48 -0
- package/dist/delete-BOUObrDw.mjs.map +1 -0
- package/dist/delete-BSLIXrAh.mjs +59 -0
- package/dist/delete-BSLIXrAh.mjs.map +1 -0
- package/dist/delete-BenBNL2p.mjs +56 -0
- package/dist/delete-BenBNL2p.mjs.map +1 -0
- package/dist/delete-Bx2oNROv.cjs +56 -0
- package/dist/delete-Bx2oNROv.cjs.map +1 -0
- package/dist/delete-CCTiCYIL.cjs +51 -0
- package/dist/delete-CCTiCYIL.cjs.map +1 -0
- package/dist/delete-CGW0VMK6.cjs +56 -0
- package/dist/delete-CGW0VMK6.cjs.map +1 -0
- package/dist/delete-CIYY59v_.cjs +48 -0
- package/dist/delete-CIYY59v_.cjs.map +1 -0
- package/dist/delete-CSSd0gmt.mjs +56 -0
- package/dist/delete-CSSd0gmt.mjs.map +1 -0
- package/dist/delete-CSs5Czlo.mjs +59 -0
- package/dist/delete-CSs5Czlo.mjs.map +1 -0
- package/dist/delete-CrOVRvMo.cjs +56 -0
- package/dist/delete-CrOVRvMo.cjs.map +1 -0
- package/dist/delete-DehKYCXh.mjs +56 -0
- package/dist/delete-DehKYCXh.mjs.map +1 -0
- package/dist/delete-DhSU-Lx2.mjs +51 -0
- package/dist/delete-DhSU-Lx2.mjs.map +1 -0
- package/dist/delete-DozSxZQ7.cjs +59 -0
- package/dist/delete-DozSxZQ7.cjs.map +1 -0
- package/dist/detail-8CXNIhKw.cjs +16 -0
- package/dist/detail-8CXNIhKw.cjs.map +1 -0
- package/dist/detail-DN5jCQ4N.mjs +10 -0
- package/dist/detail-DN5jCQ4N.mjs.map +1 -0
- package/dist/download-oFGzg30E.mjs +68 -0
- package/dist/download-oFGzg30E.mjs.map +1 -0
- package/dist/download-ogGbb3FU.cjs +68 -0
- package/dist/download-ogGbb3FU.cjs.map +1 -0
- package/dist/erd-lKC5NB2l.cjs +124 -0
- package/dist/erd-lKC5NB2l.cjs.map +1 -0
- package/dist/erd-zDoF6I_y.mjs +123 -0
- package/dist/erd-zDoF6I_y.mjs.map +1 -0
- package/dist/get-BBOKSXkh.cjs +48 -0
- package/dist/get-BBOKSXkh.cjs.map +1 -0
- package/dist/get-BHniACk5.cjs +57 -0
- package/dist/get-BHniACk5.cjs.map +1 -0
- package/dist/get-BtmzDaVn.mjs +47 -0
- package/dist/get-BtmzDaVn.mjs.map +1 -0
- package/dist/get-CVV3h6HR.cjs +47 -0
- package/dist/get-CVV3h6HR.cjs.map +1 -0
- package/dist/get-CgEgETQa.mjs +52 -0
- package/dist/get-CgEgETQa.mjs.map +1 -0
- package/dist/get-DB80UNSR.mjs +47 -0
- package/dist/get-DB80UNSR.mjs.map +1 -0
- package/dist/get-DBxhbN1G.mjs +57 -0
- package/dist/get-DBxhbN1G.mjs.map +1 -0
- package/dist/get-DDB89cOs.mjs +48 -0
- package/dist/get-DDB89cOs.mjs.map +1 -0
- package/dist/get-DPGx1zU4.mjs +56 -0
- package/dist/get-DPGx1zU4.mjs.map +1 -0
- package/dist/get-IOU__2RP.cjs +52 -0
- package/dist/get-IOU__2RP.cjs.map +1 -0
- package/dist/get-KdWfYINc.cjs +47 -0
- package/dist/get-KdWfYINc.cjs.map +1 -0
- package/dist/get-jwXRlIBJ.cjs +57 -0
- package/dist/get-jwXRlIBJ.cjs.map +1 -0
- package/dist/group-roles-BEEzLxPX.mjs +36 -0
- package/dist/group-roles-BEEzLxPX.mjs.map +1 -0
- package/dist/group-roles-Bl_mEodO.cjs +59 -0
- package/dist/group-roles-Bl_mEodO.cjs.map +1 -0
- package/dist/invite-DsOCKGTJ.mjs +66 -0
- package/dist/invite-DsOCKGTJ.mjs.map +1 -0
- package/dist/invite-Dts9uNQL.cjs +66 -0
- package/dist/invite-Dts9uNQL.cjs.map +1 -0
- package/dist/key-BogfSiz_.mjs +17 -0
- package/dist/key-BogfSiz_.mjs.map +1 -0
- package/dist/key-Czwiu2pW.cjs +17 -0
- package/dist/key-Czwiu2pW.cjs.map +1 -0
- package/dist/link-BluFyxEL.mjs +42 -0
- package/dist/link-BluFyxEL.mjs.map +1 -0
- package/dist/link-DYu1Vjlw.cjs +42 -0
- package/dist/link-DYu1Vjlw.cjs.map +1 -0
- package/dist/list-2BpPj4Z0.cjs +40 -0
- package/dist/list-2BpPj4Z0.cjs.map +1 -0
- package/dist/list-57TUfNFd.mjs +48 -0
- package/dist/list-57TUfNFd.mjs.map +1 -0
- package/dist/list-60NcDr0q.cjs +81 -0
- package/dist/list-60NcDr0q.cjs.map +1 -0
- package/dist/list-BRh59EqI.cjs +35 -0
- package/dist/list-BRh59EqI.cjs.map +1 -0
- package/dist/list-BwfpuhmJ.cjs +37 -0
- package/dist/list-BwfpuhmJ.cjs.map +1 -0
- package/dist/list-CJuefq_I.cjs +82 -0
- package/dist/list-CJuefq_I.cjs.map +1 -0
- package/dist/list-CYE9Exi3.cjs +72 -0
- package/dist/list-CYE9Exi3.cjs.map +1 -0
- package/dist/list-CbvEh7eA.mjs +35 -0
- package/dist/list-CbvEh7eA.mjs.map +1 -0
- package/dist/list-CfIeReBx.mjs +82 -0
- package/dist/list-CfIeReBx.mjs.map +1 -0
- package/dist/list-CxHDoXjv.mjs +81 -0
- package/dist/list-CxHDoXjv.mjs.map +1 -0
- package/dist/list-D0-QrWmn.cjs +51 -0
- package/dist/list-D0-QrWmn.cjs.map +1 -0
- package/dist/list-D24J_Qbm.mjs +49 -0
- package/dist/list-D24J_Qbm.mjs.map +1 -0
- package/dist/list-D5PSDMWw.mjs +51 -0
- package/dist/list-D5PSDMWw.mjs.map +1 -0
- package/dist/list-DRKF2uKW.cjs +95 -0
- package/dist/list-DRKF2uKW.cjs.map +1 -0
- package/dist/list-DdJ05juK.mjs +72 -0
- package/dist/list-DdJ05juK.mjs.map +1 -0
- package/dist/list-DlJssPwy.cjs +48 -0
- package/dist/list-DlJssPwy.cjs.map +1 -0
- package/dist/list-V3W6hvOa.cjs +49 -0
- package/dist/list-V3W6hvOa.cjs.map +1 -0
- package/dist/list-rAn3uOA7.mjs +37 -0
- package/dist/list-rAn3uOA7.mjs.map +1 -0
- package/dist/list-syVDGkVR.mjs +40 -0
- package/dist/list-syVDGkVR.mjs.map +1 -0
- package/dist/list-yQZLzkC7.mjs +95 -0
- package/dist/list-yQZLzkC7.mjs.map +1 -0
- package/dist/login-2XcHd4wn.cjs +212 -0
- package/dist/login-2XcHd4wn.cjs.map +1 -0
- package/dist/login-FE_dbWMo.mjs +211 -0
- package/dist/login-FE_dbWMo.mjs.map +1 -0
- package/dist/logout-BDbWrGBm.mjs +35 -0
- package/dist/logout-BDbWrGBm.mjs.map +1 -0
- package/dist/logout-DC5TMJ5_.cjs +35 -0
- package/dist/logout-DC5TMJ5_.cjs.map +1 -0
- package/dist/management-BaN1Nynl.mjs +19 -0
- package/dist/management-BaN1Nynl.mjs.map +1 -0
- package/dist/management-DHXxdCra.cjs +19 -0
- package/dist/management-DHXxdCra.cjs.map +1 -0
- package/dist/mask-B1qD73jb.mjs +22 -0
- package/dist/mask-B1qD73jb.mjs.map +1 -0
- package/dist/mask-CqYLib9p.cjs +40 -0
- package/dist/mask-CqYLib9p.cjs.map +1 -0
- package/dist/oauth-client-CdD0evAV.cjs +170 -0
- package/dist/oauth-client-CdD0evAV.cjs.map +1 -0
- package/dist/oauth-client-QHuDa4fW.mjs +139 -0
- package/dist/oauth-client-QHuDa4fW.mjs.map +1 -0
- package/dist/object-BfUf8Y6w.mjs +20 -0
- package/dist/object-BfUf8Y6w.mjs.map +1 -0
- package/dist/object-DT7UEW9G.cjs +20 -0
- package/dist/object-DT7UEW9G.cjs.map +1 -0
- package/dist/org-C4cVovOM.cjs +14 -0
- package/dist/org-C4cVovOM.cjs.map +1 -0
- package/dist/org-CPhTRTks.mjs +14 -0
- package/dist/org-CPhTRTks.mjs.map +1 -0
- package/dist/org-context-Bewx2NEW.cjs +30 -0
- package/dist/org-context-Bewx2NEW.cjs.map +1 -0
- package/dist/org-context-D0dwWC2M.mjs +25 -0
- package/dist/org-context-D0dwWC2M.mjs.map +1 -0
- package/dist/parse-BeO2IwfI.cjs +229 -0
- package/dist/parse-BeO2IwfI.cjs.map +1 -0
- package/dist/parse-CA5fBB3x.mjs +150 -0
- package/dist/parse-CA5fBB3x.mjs.map +1 -0
- package/dist/project-CNr9xMny.cjs +20 -0
- package/dist/project-CNr9xMny.cjs.map +1 -0
- package/dist/project-DFoHcXi5.mjs +20 -0
- package/dist/project-DFoHcXi5.mjs.map +1 -0
- package/dist/project-name-CEoM-OL4.cjs +18 -0
- package/dist/project-name-CEoM-OL4.cjs.map +1 -0
- package/dist/project-name-DNMejnzZ.mjs +12 -0
- package/dist/project-name-DNMejnzZ.mjs.map +1 -0
- package/dist/project-user-9D7Ey_Fu.mjs +20 -0
- package/dist/project-user-9D7Ey_Fu.mjs.map +1 -0
- package/dist/project-user-DTPFjyfZ.cjs +20 -0
- package/dist/project-user-DTPFjyfZ.cjs.map +1 -0
- package/dist/push-0u6PDz4E.cjs +166 -0
- package/dist/push-0u6PDz4E.cjs.map +1 -0
- package/dist/push-D7co0keA.mjs +166 -0
- package/dist/push-D7co0keA.mjs.map +1 -0
- package/dist/run-codegen-Ceeosw5x.cjs +272 -0
- package/dist/run-codegen-Ceeosw5x.cjs.map +1 -0
- package/dist/run-codegen-DgaFaIQ1.mjs +190 -0
- package/dist/run-codegen-DgaFaIQ1.mjs.map +1 -0
- package/dist/run-with-context-CVhmzAFZ.mjs +876 -0
- package/dist/run-with-context-CVhmzAFZ.mjs.map +1 -0
- package/dist/run-with-context-DJNnEigg.cjs +943 -0
- package/dist/run-with-context-DJNnEigg.cjs.map +1 -0
- package/dist/schema-DDzrgjkT.mjs +20 -0
- package/dist/schema-DDzrgjkT.mjs.map +1 -0
- package/dist/schema-DdhyEh81.cjs +20 -0
- package/dist/schema-DdhyEh81.cjs.map +1 -0
- package/dist/shared-CZZimGxc.mjs +35 -0
- package/dist/shared-CZZimGxc.mjs.map +1 -0
- package/dist/shared-DHRPzzKl.cjs +59 -0
- package/dist/shared-DHRPzzKl.cjs.map +1 -0
- package/dist/status-Dq_NJE71.cjs +49 -0
- package/dist/status-Dq_NJE71.cjs.map +1 -0
- package/dist/status-fWqXzV0P.mjs +49 -0
- package/dist/status-fWqXzV0P.mjs.map +1 -0
- package/dist/table-C74eOSh8.cjs +27 -0
- package/dist/table-C74eOSh8.cjs.map +1 -0
- package/dist/table-MHEfbnWO.mjs +20 -0
- package/dist/table-MHEfbnWO.mjs.map +1 -0
- package/dist/table-event-C16cp9nq.mjs +72 -0
- package/dist/table-event-C16cp9nq.mjs.map +1 -0
- package/dist/table-event-D7PPuS7E.cjs +101 -0
- package/dist/table-event-D7PPuS7E.cjs.map +1 -0
- package/dist/token-store--9GYVL7N.cjs +139 -0
- package/dist/token-store--9GYVL7N.cjs.map +1 -0
- package/dist/token-store-reCGF86F.mjs +124 -0
- package/dist/token-store-reCGF86F.mjs.map +1 -0
- package/dist/update-8e3u4jKa.mjs +109 -0
- package/dist/update-8e3u4jKa.mjs.map +1 -0
- package/dist/update-CDLviRuu.cjs +73 -0
- package/dist/update-CDLviRuu.cjs.map +1 -0
- package/dist/update-CSiOfiPL.mjs +117 -0
- package/dist/update-CSiOfiPL.mjs.map +1 -0
- package/dist/update-CjbcI8Qc.mjs +61 -0
- package/dist/update-CjbcI8Qc.mjs.map +1 -0
- package/dist/update-Cktd0zXA.cjs +109 -0
- package/dist/update-Cktd0zXA.cjs.map +1 -0
- package/dist/update-D-X32BVW.cjs +117 -0
- package/dist/update-D-X32BVW.cjs.map +1 -0
- package/dist/update-DfYV_TQb.mjs +171 -0
- package/dist/update-DfYV_TQb.mjs.map +1 -0
- package/dist/update-OWC5K8Ne.cjs +61 -0
- package/dist/update-OWC5K8Ne.cjs.map +1 -0
- package/dist/update-ap5Qv1Yl.cjs +171 -0
- package/dist/update-ap5Qv1Yl.cjs.map +1 -0
- package/dist/update-yscrx6WQ.mjs +73 -0
- package/dist/update-yscrx6WQ.mjs.map +1 -0
- package/dist/upload-C43ZXxyb.cjs +95 -0
- package/dist/upload-C43ZXxyb.cjs.map +1 -0
- package/dist/upload-DGgJ1TQk.mjs +94 -0
- package/dist/upload-DGgJ1TQk.mjs.map +1 -0
- package/dist/validate-BpxZ8LTl.cjs +31 -0
- package/dist/validate-BpxZ8LTl.cjs.map +1 -0
- package/dist/validate-Ca0CRo16.mjs +31 -0
- package/dist/validate-Ca0CRo16.mjs.map +1 -0
- package/dist/webhook-3zs6Ulxd.mjs +20 -0
- package/dist/webhook-3zs6Ulxd.mjs.map +1 -0
- package/dist/webhook-BsygMMf-.cjs +20 -0
- package/dist/webhook-BsygMMf-.cjs.map +1 -0
- package/package.json +29 -18
- package/bin/index.js +0 -3
- package/dist/cli.cjs +0 -1978
- package/dist/cli.cjs.map +0 -1
- package/dist/cli.d.cts +0 -2
- package/dist/cli.d.ts +0 -2
- package/dist/cli.js +0 -1954
- package/dist/cli.js.map +0 -1
- package/dist/config/index.js +0 -81
- package/dist/config/index.js.map +0 -1
package/dist/cli.js
DELETED
|
@@ -1,1954 +0,0 @@
|
|
|
1
|
-
// src/cli.ts
|
|
2
|
-
import { Command as Command8, program } from "commander";
|
|
3
|
-
|
|
4
|
-
// src/cms/generate/command.ts
|
|
5
|
-
import { Command } from "commander";
|
|
6
|
-
|
|
7
|
-
// src/lib/load-config.ts
|
|
8
|
-
import esbuild from "esbuild";
|
|
9
|
-
import { OrizmConfigDef } from "@orizm/common/config-validator";
|
|
10
|
-
import * as v from "valibot";
|
|
11
|
-
async function loadConfig(configFile) {
|
|
12
|
-
const buildResult = await esbuild.build({
|
|
13
|
-
entryPoints: [configFile],
|
|
14
|
-
bundle: true,
|
|
15
|
-
write: false,
|
|
16
|
-
format: "esm",
|
|
17
|
-
target: "node22",
|
|
18
|
-
platform: "node"
|
|
19
|
-
});
|
|
20
|
-
const moduleURL = `data:text/javascript,${encodeURIComponent(
|
|
21
|
-
buildResult.outputFiles[0].text
|
|
22
|
-
)}`;
|
|
23
|
-
const { default: orizmConfigRaw } = await import(moduleURL);
|
|
24
|
-
return v.parse(OrizmConfigDef, orizmConfigRaw);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// src/lib/cli-spinner.ts
|
|
28
|
-
import readline from "readline";
|
|
29
|
-
|
|
30
|
-
// src/lib/cli-symbol.ts
|
|
31
|
-
import chalk from "chalk";
|
|
32
|
-
var success = chalk.green("\u2713");
|
|
33
|
-
var error = chalk.red("\u2717");
|
|
34
|
-
|
|
35
|
-
// src/lib/cli-cursor.ts
|
|
36
|
-
function hide() {
|
|
37
|
-
process.stdout.write("\x1B[?25l");
|
|
38
|
-
}
|
|
39
|
-
function show() {
|
|
40
|
-
process.stdout.write("\x1B[?25h");
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// src/lib/cli-spinner.ts
|
|
44
|
-
var FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
45
|
-
var FRAME_INTERVAL = 80;
|
|
46
|
-
var Spinner = class {
|
|
47
|
-
text = "";
|
|
48
|
-
currentFrame = 0;
|
|
49
|
-
timer = null;
|
|
50
|
-
isSpinning = false;
|
|
51
|
-
start(text) {
|
|
52
|
-
if (text) {
|
|
53
|
-
this.text = text;
|
|
54
|
-
}
|
|
55
|
-
if (this.isSpinning) {
|
|
56
|
-
return this;
|
|
57
|
-
}
|
|
58
|
-
this.isSpinning = true;
|
|
59
|
-
this.currentFrame = 0;
|
|
60
|
-
hide();
|
|
61
|
-
this.render();
|
|
62
|
-
this.timer = setInterval(() => {
|
|
63
|
-
this.render();
|
|
64
|
-
}, FRAME_INTERVAL);
|
|
65
|
-
return this;
|
|
66
|
-
}
|
|
67
|
-
stop() {
|
|
68
|
-
if (!this.isSpinning) {
|
|
69
|
-
return this;
|
|
70
|
-
}
|
|
71
|
-
this.isSpinning = false;
|
|
72
|
-
if (this.timer) {
|
|
73
|
-
clearInterval(this.timer);
|
|
74
|
-
this.timer = null;
|
|
75
|
-
}
|
|
76
|
-
readline.clearLine(process.stdout, 0);
|
|
77
|
-
readline.cursorTo(process.stdout, 0);
|
|
78
|
-
show();
|
|
79
|
-
return this;
|
|
80
|
-
}
|
|
81
|
-
succeed(text) {
|
|
82
|
-
this.stop();
|
|
83
|
-
const finalText = text || this.text;
|
|
84
|
-
console.log(`${success} ${finalText}`);
|
|
85
|
-
}
|
|
86
|
-
render() {
|
|
87
|
-
const frame = FRAMES[this.currentFrame];
|
|
88
|
-
this.currentFrame = (this.currentFrame + 1) % FRAMES.length;
|
|
89
|
-
readline.clearLine(process.stdout, 0);
|
|
90
|
-
readline.cursorTo(process.stdout, 0);
|
|
91
|
-
process.stdout.write(`${frame} ${this.text}`);
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
function createSpinner() {
|
|
95
|
-
return new Spinner();
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// src/lib/handle-error.ts
|
|
99
|
-
import * as v3 from "valibot";
|
|
100
|
-
import chalk3 from "chalk";
|
|
101
|
-
|
|
102
|
-
// src/lib/display-valibot-error.ts
|
|
103
|
-
import * as v2 from "valibot";
|
|
104
|
-
import chalk2 from "chalk";
|
|
105
|
-
function displayValibotError(error2) {
|
|
106
|
-
if (!v2.isValiError(error2)) {
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
console.error(`Error: ${error2.issues.length} problem(s) found.`);
|
|
110
|
-
console.error(buildValiErrorMessage(error2));
|
|
111
|
-
}
|
|
112
|
-
function buildValiErrorMessage(e, options) {
|
|
113
|
-
const { color = true } = options ?? {};
|
|
114
|
-
return e.issues.map((issue) => {
|
|
115
|
-
const path3 = getPath(issue);
|
|
116
|
-
return ` ${getIssueMessage(issue.message, color)} (at ${getLocationPath(path3, color)})`;
|
|
117
|
-
}).join("\n");
|
|
118
|
-
}
|
|
119
|
-
function getIssueMessage(message, color) {
|
|
120
|
-
return color ? chalk2.red(message) : message;
|
|
121
|
-
}
|
|
122
|
-
function getLocationPath(path3, color) {
|
|
123
|
-
return color ? chalk2.yellow(path3) : path3;
|
|
124
|
-
}
|
|
125
|
-
function getPath(issue) {
|
|
126
|
-
const issueDotPath = v2.getDotPath(issue);
|
|
127
|
-
const pathInfo = issue.path;
|
|
128
|
-
if (!issueDotPath || !pathInfo) {
|
|
129
|
-
return "";
|
|
130
|
-
}
|
|
131
|
-
const pathParts = issueDotPath.split(".");
|
|
132
|
-
let pathInfoIndex = 0;
|
|
133
|
-
for (let i = 0; i < pathParts.length; i++) {
|
|
134
|
-
const part = pathParts[i];
|
|
135
|
-
if (!isNumberIndex(part)) {
|
|
136
|
-
continue;
|
|
137
|
-
}
|
|
138
|
-
const index = parseInt(part);
|
|
139
|
-
for (let j = pathInfoIndex; j < pathInfo.length; j++) {
|
|
140
|
-
const pathItem = pathInfo[j];
|
|
141
|
-
if (pathItem.type === "array" && pathItem.key === index) {
|
|
142
|
-
if (pathItem.value != null && typeof pathItem.value === "object" && "name" in pathItem.value) {
|
|
143
|
-
pathParts[i] = String(pathItem.value.name);
|
|
144
|
-
pathInfoIndex = j + 1;
|
|
145
|
-
break;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
return pathParts.join(".");
|
|
151
|
-
}
|
|
152
|
-
function isNumberIndex(part) {
|
|
153
|
-
return /^\d+$/.test(part);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// src/lib/handle-error.ts
|
|
157
|
-
function handleError(error2) {
|
|
158
|
-
show();
|
|
159
|
-
if (v3.isValiError(error2)) {
|
|
160
|
-
console.error();
|
|
161
|
-
displayValibotError(error2);
|
|
162
|
-
console.error();
|
|
163
|
-
process.exit(1);
|
|
164
|
-
}
|
|
165
|
-
console.error();
|
|
166
|
-
console.error(
|
|
167
|
-
chalk3.red(
|
|
168
|
-
"Something went wrong. Please check the error below for more details."
|
|
169
|
-
)
|
|
170
|
-
);
|
|
171
|
-
console.error();
|
|
172
|
-
console.error(error2);
|
|
173
|
-
console.error();
|
|
174
|
-
process.exit(1);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
// src/cms/generate/generator.ts
|
|
178
|
-
import { mkdir, writeFile } from "fs/promises";
|
|
179
|
-
import path from "path";
|
|
180
|
-
|
|
181
|
-
// src/lib/format-ts-with-prettier.ts
|
|
182
|
-
import * as prettier from "prettier/standalone";
|
|
183
|
-
import prettierPluginEstree from "prettier/plugins/estree.js";
|
|
184
|
-
import prettierPluginTypeScript from "prettier/plugins/typescript.js";
|
|
185
|
-
function formatTsWithPrettier(code) {
|
|
186
|
-
return prettier.format(code, {
|
|
187
|
-
parser: "typescript",
|
|
188
|
-
plugins: [prettierPluginEstree, prettierPluginTypeScript]
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// src/lib/render-helpers.ts
|
|
193
|
-
function toCodeTypeName(str) {
|
|
194
|
-
str = str.charAt(0).toUpperCase() + str.slice(1);
|
|
195
|
-
return str.replace(/_([a-z])/g, (g) => g[1].toUpperCase());
|
|
196
|
-
}
|
|
197
|
-
function typeName(column, moduleSuffix = "") {
|
|
198
|
-
switch (column.type) {
|
|
199
|
-
case "reference":
|
|
200
|
-
return "string";
|
|
201
|
-
case "module":
|
|
202
|
-
return toCodeTypeName(column.moduleName ?? "") + moduleSuffix;
|
|
203
|
-
case "module-array":
|
|
204
|
-
return toCodeTypeName(column.moduleName ?? "") + moduleSuffix + "[]";
|
|
205
|
-
case "json":
|
|
206
|
-
return "unknown";
|
|
207
|
-
case "storage":
|
|
208
|
-
return "StorageItemType";
|
|
209
|
-
default:
|
|
210
|
-
return column.type;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
function nullableSuffix(column) {
|
|
214
|
-
return !column.required && column.type !== "module-array" ? " | null" : "";
|
|
215
|
-
}
|
|
216
|
-
function filterRefColumns(columns) {
|
|
217
|
-
return columns.filter(
|
|
218
|
-
(c) => c.type === "reference" && c.tableName !== void 0 && c.includeName !== void 0 && c.includeName !== "" || c.type === "module" && c.moduleName !== void 0 || c.type === "module-array" && c.moduleName !== void 0
|
|
219
|
-
);
|
|
220
|
-
}
|
|
221
|
-
function getIncludeName(column) {
|
|
222
|
-
return column.type === "reference" ? column.includeName || column.name : column.name;
|
|
223
|
-
}
|
|
224
|
-
function getIncludeType(column) {
|
|
225
|
-
if (column.type === "reference" && column.tableName) {
|
|
226
|
-
return toCodeTypeName(column.tableName) + "__Descriptor";
|
|
227
|
-
}
|
|
228
|
-
if (column.type === "module" && column.moduleName) {
|
|
229
|
-
return `_ModuleRef<${toCodeTypeName(column.moduleName)}__Descriptor>`;
|
|
230
|
-
}
|
|
231
|
-
if (column.type === "module-array" && column.moduleName) {
|
|
232
|
-
return `_ArrayModuleRef<${toCodeTypeName(column.moduleName)}__Descriptor>`;
|
|
233
|
-
}
|
|
234
|
-
return "";
|
|
235
|
-
}
|
|
236
|
-
function renderColumnField(col, options) {
|
|
237
|
-
const optional2 = options?.optional === true ? "?" : "";
|
|
238
|
-
const suffix = options?.suffix ?? "";
|
|
239
|
-
return `${col.name}${optional2}: ${typeName(col, suffix)}${nullableSuffix(col)};`;
|
|
240
|
-
}
|
|
241
|
-
function renderTypeBlock(name, fields) {
|
|
242
|
-
return `export type ${name} = {
|
|
243
|
-
${fields.join("\n")}
|
|
244
|
-
};`;
|
|
245
|
-
}
|
|
246
|
-
function renderRefsFieldLines(columns) {
|
|
247
|
-
const refCols = filterRefColumns(columns);
|
|
248
|
-
if (refCols.length === 0) return ["refs: object;"];
|
|
249
|
-
return [
|
|
250
|
-
"refs: {",
|
|
251
|
-
...refCols.map((c) => `${getIncludeName(c)}: ${getIncludeType(c)};`),
|
|
252
|
-
"}"
|
|
253
|
-
];
|
|
254
|
-
}
|
|
255
|
-
function renderUniqueFieldLines(table) {
|
|
256
|
-
const uniqueIndexes = (table.indexes ?? []).filter((i) => i.unique);
|
|
257
|
-
if (uniqueIndexes.length === 0) return ["unique: [];"];
|
|
258
|
-
const entries = uniqueIndexes.map((index) => {
|
|
259
|
-
const cols = index.columns.map((colName) => {
|
|
260
|
-
const col = table.columns.find((c) => c.name === colName);
|
|
261
|
-
if (!col) throw new Error(`column ${colName} not found`);
|
|
262
|
-
const nullable = !col.required && index.nullsNotDistinct ? " | null" : "";
|
|
263
|
-
return `${col.name}:${typeName(col)}${nullable},`;
|
|
264
|
-
});
|
|
265
|
-
return `{ ${cols.join("")} },`;
|
|
266
|
-
});
|
|
267
|
-
return ["unique: [", ...entries, "]"];
|
|
268
|
-
}
|
|
269
|
-
function renderModuleRowTypeBlock(mod) {
|
|
270
|
-
return renderTypeBlock(toCodeTypeName(mod.name), [
|
|
271
|
-
"id: string;",
|
|
272
|
-
...mod.columns.map((col) => renderColumnField(col))
|
|
273
|
-
]);
|
|
274
|
-
}
|
|
275
|
-
function renderModuleDescriptorBlock(mod) {
|
|
276
|
-
const name = toCodeTypeName(mod.name);
|
|
277
|
-
return renderTypeBlock(`${name}__Descriptor`, [
|
|
278
|
-
`row: ${name};`,
|
|
279
|
-
...renderRefsFieldLines(mod.columns),
|
|
280
|
-
"unique: [];"
|
|
281
|
-
]);
|
|
282
|
-
}
|
|
283
|
-
function renderPreamble(importFrom) {
|
|
284
|
-
return `// This file was automatically generated and should not be edited.
|
|
285
|
-
|
|
286
|
-
import { FormValidationRules, StorageItemType } from "${importFrom}";
|
|
287
|
-
|
|
288
|
-
// Utilities
|
|
289
|
-
type _ModuleRef<T> = T & _ModuleDescriptor;
|
|
290
|
-
type _ModuleDescriptor = {
|
|
291
|
-
isModule: true;
|
|
292
|
-
};
|
|
293
|
-
type _ArrayModuleRef<T> = T & _ArrayModuleDescriptor;
|
|
294
|
-
type _ArrayModuleDescriptor = {
|
|
295
|
-
isModuleArray: true;
|
|
296
|
-
};`;
|
|
297
|
-
}
|
|
298
|
-
function renderSection(title, blocks) {
|
|
299
|
-
if (blocks.length === 0) return "";
|
|
300
|
-
return `// ${title}
|
|
301
|
-
${blocks.join("\n\n")}`;
|
|
302
|
-
}
|
|
303
|
-
function renderWebhookTypesSection(tables) {
|
|
304
|
-
const lines = [
|
|
305
|
-
"// Webhook types",
|
|
306
|
-
'export type WebhookEvent = "content.create" | "content.update" | "content.delete";',
|
|
307
|
-
"",
|
|
308
|
-
"type WebhookPayloadBase = {",
|
|
309
|
-
" event: WebhookEvent;",
|
|
310
|
-
" timestamp: string;",
|
|
311
|
-
" project: string;",
|
|
312
|
-
"};",
|
|
313
|
-
""
|
|
314
|
-
];
|
|
315
|
-
if (tables.length > 0) {
|
|
316
|
-
const unionMembers = tables.map((t) => {
|
|
317
|
-
const name = toCodeTypeName(t.name);
|
|
318
|
-
return `| {
|
|
319
|
-
table: "${t.name}";
|
|
320
|
-
content: ${name};
|
|
321
|
-
old?: ${name};
|
|
322
|
-
}`;
|
|
323
|
-
}).join("\n");
|
|
324
|
-
lines.push(
|
|
325
|
-
`export type WebhookPayload = WebhookPayloadBase & (
|
|
326
|
-
${unionMembers}
|
|
327
|
-
);`
|
|
328
|
-
);
|
|
329
|
-
} else {
|
|
330
|
-
lines.push("export type WebhookPayload = WebhookPayloadBase;");
|
|
331
|
-
}
|
|
332
|
-
return lines.join("\n");
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
// src/cms/generate/generator.ts
|
|
336
|
-
async function generate(options) {
|
|
337
|
-
const config = options.config;
|
|
338
|
-
await mkdir(options.output, { recursive: true });
|
|
339
|
-
const renderedTypes = await renderTypes(config);
|
|
340
|
-
await writeFile(
|
|
341
|
-
path.join(options.output, "types.ts"),
|
|
342
|
-
renderedTypes,
|
|
343
|
-
"utf-8"
|
|
344
|
-
);
|
|
345
|
-
const renderedClient = await renderClient(config);
|
|
346
|
-
await writeFile(
|
|
347
|
-
path.join(options.output, "client.ts"),
|
|
348
|
-
renderedClient,
|
|
349
|
-
"utf-8"
|
|
350
|
-
);
|
|
351
|
-
}
|
|
352
|
-
async function renderTypes(config) {
|
|
353
|
-
const submissionTables = config.tables.filter((t) => t.enableForm).map((t) => ({
|
|
354
|
-
name: t.name + "__submission",
|
|
355
|
-
columns: t.formOptions?.submissionColumns ?? [],
|
|
356
|
-
isSubmissions: true
|
|
357
|
-
}));
|
|
358
|
-
const allTables = [...config.tables, ...submissionTables];
|
|
359
|
-
const modules = config.tableModules ?? [];
|
|
360
|
-
const source = [
|
|
361
|
-
renderPreamble("@orizm/cms-sdk/common"),
|
|
362
|
-
renderSection("Tables", allTables.map(renderTableTypes)),
|
|
363
|
-
renderSection("Module types", modules.map(renderModuleTypes)),
|
|
364
|
-
// CMS: モジュール descriptor 間は空行なし(スナップショット互換)
|
|
365
|
-
"// Descriptor types\n" + [
|
|
366
|
-
...allTables.map(renderTableDescriptor),
|
|
367
|
-
modules.map(renderModuleDescriptorBlock).join("\n")
|
|
368
|
-
].join("\n\n"),
|
|
369
|
-
renderWebhookTypesSection(allTables)
|
|
370
|
-
].filter(Boolean).join("\n\n\n");
|
|
371
|
-
return await formatTsWithPrettier(source);
|
|
372
|
-
}
|
|
373
|
-
function renderTableTypes(table) {
|
|
374
|
-
const cols = table.columns;
|
|
375
|
-
const name = toCodeTypeName(table.name);
|
|
376
|
-
const rowType = renderTypeBlock(name, [
|
|
377
|
-
"id: string;",
|
|
378
|
-
"createdAt: string;",
|
|
379
|
-
"updatedAt: string;",
|
|
380
|
-
...!table.isSubmissions ? [
|
|
381
|
-
"group: string | null;",
|
|
382
|
-
"publishedAt: string | null;",
|
|
383
|
-
"_draft: boolean | null;",
|
|
384
|
-
"_published: boolean | null;",
|
|
385
|
-
"scheduledPublishAt: string | null;",
|
|
386
|
-
"scheduledUnpublishAt: string | null;"
|
|
387
|
-
] : [
|
|
388
|
-
"_formId: string;",
|
|
389
|
-
"_content: unknown;",
|
|
390
|
-
"_formSchema: unknown;",
|
|
391
|
-
"_attachments: StorageItemType[];"
|
|
392
|
-
],
|
|
393
|
-
...cols.map((col) => renderColumnField(col)),
|
|
394
|
-
...table.enableForm ? ["formSchema: FormValidationRules;"] : []
|
|
395
|
-
]);
|
|
396
|
-
const createType = renderTypeBlock(`${name}CreateInput`, [
|
|
397
|
-
...!table.isSubmissions ? [
|
|
398
|
-
"group?: string | null;",
|
|
399
|
-
"publishedAt?: string | null;",
|
|
400
|
-
"scheduledPublishAt?: string | null;",
|
|
401
|
-
"scheduledUnpublishAt?: string | null;",
|
|
402
|
-
"createdAt?: string;"
|
|
403
|
-
] : [],
|
|
404
|
-
...cols.map(
|
|
405
|
-
(col) => renderColumnField(col, {
|
|
406
|
-
optional: !col.required,
|
|
407
|
-
suffix: "CreateInput"
|
|
408
|
-
})
|
|
409
|
-
),
|
|
410
|
-
...table.enableForm ? ["formSchema: FormValidationRules;"] : []
|
|
411
|
-
]);
|
|
412
|
-
const updateType = renderTypeBlock(`${name}UpdateInput`, [
|
|
413
|
-
...cols.filter((col) => !col.readOnly).map(
|
|
414
|
-
(col) => renderColumnField(col, { optional: true, suffix: "UpdateInput" })
|
|
415
|
-
),
|
|
416
|
-
...!table.isSubmissions ? [
|
|
417
|
-
"publishedAt?: string | null;",
|
|
418
|
-
"scheduledPublishAt?: string | null;",
|
|
419
|
-
"scheduledUnpublishAt?: string | null;",
|
|
420
|
-
"createdAt?: string;"
|
|
421
|
-
] : [],
|
|
422
|
-
...table.enableForm ? ["formSchema: FormValidationRules;"] : []
|
|
423
|
-
]);
|
|
424
|
-
return [rowType, createType, updateType].join("\n\n");
|
|
425
|
-
}
|
|
426
|
-
function renderModuleTypes(mod) {
|
|
427
|
-
const name = toCodeTypeName(mod.name);
|
|
428
|
-
const cols = mod.columns;
|
|
429
|
-
const rowType = renderModuleRowTypeBlock(mod);
|
|
430
|
-
const createType = renderTypeBlock(`${name}CreateInput`, [
|
|
431
|
-
...cols.map(
|
|
432
|
-
(col) => renderColumnField(col, {
|
|
433
|
-
optional: !col.required,
|
|
434
|
-
suffix: "CreateInput"
|
|
435
|
-
})
|
|
436
|
-
)
|
|
437
|
-
]);
|
|
438
|
-
const updateType = renderTypeBlock(`${name}UpdateInput`, [
|
|
439
|
-
"id?: string;",
|
|
440
|
-
...cols.map(
|
|
441
|
-
(col) => renderColumnField(col, {
|
|
442
|
-
optional: !col.required,
|
|
443
|
-
suffix: "UpdateInput"
|
|
444
|
-
})
|
|
445
|
-
)
|
|
446
|
-
]);
|
|
447
|
-
return [rowType, createType, updateType].join("\n\n");
|
|
448
|
-
}
|
|
449
|
-
function renderTableDescriptor(table) {
|
|
450
|
-
const name = toCodeTypeName(table.name);
|
|
451
|
-
return renderTypeBlock(`${name}__Descriptor`, [
|
|
452
|
-
`row: ${name};`,
|
|
453
|
-
`create: ${name}CreateInput;`,
|
|
454
|
-
`update: ${name}UpdateInput;`,
|
|
455
|
-
...renderRefsFieldLines(table.columns),
|
|
456
|
-
...renderUniqueFieldLines(table),
|
|
457
|
-
...table.enableDrafts ? ["enableDrafts: true;"] : [],
|
|
458
|
-
...table.enableForm ? [`submissionDescriptor: ${name}_Submission__Descriptor;`] : ["submissionDescriptor: never;"]
|
|
459
|
-
]);
|
|
460
|
-
}
|
|
461
|
-
async function renderClient(config) {
|
|
462
|
-
const tableEntries = config.tables.map(
|
|
463
|
-
(t) => `${t.name}: this.client.getTableClient<Models.${toCodeTypeName(t.name)}__Descriptor>("${t.name}"),`
|
|
464
|
-
).join("\n");
|
|
465
|
-
const bucketEntries = (config.buckets ?? []).map((b) => `${b.name}: this.client.getBucketClient("${b.name}"),`).join("\n");
|
|
466
|
-
const source = `// This file was automatically generated and should not be edited.
|
|
467
|
-
|
|
468
|
-
import { OrizmCMSClient } from "@orizm/cms-sdk";
|
|
469
|
-
|
|
470
|
-
import * as Models from "./types";
|
|
471
|
-
|
|
472
|
-
export class CMSClient {
|
|
473
|
-
constructor(protected client: OrizmCMSClient) {
|
|
474
|
-
this.tables = {
|
|
475
|
-
${tableEntries}
|
|
476
|
-
};
|
|
477
|
-
|
|
478
|
-
this.buckets = {
|
|
479
|
-
${bucketEntries}
|
|
480
|
-
};
|
|
481
|
-
|
|
482
|
-
this.userManagement = this.client.userManagement;
|
|
483
|
-
|
|
484
|
-
this.userinfo = this.client.userinfo;
|
|
485
|
-
|
|
486
|
-
this.auth = this.client.auth;
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
readonly tables;
|
|
490
|
-
readonly buckets;
|
|
491
|
-
readonly userManagement;
|
|
492
|
-
readonly userinfo;
|
|
493
|
-
readonly auth;
|
|
494
|
-
}
|
|
495
|
-
`;
|
|
496
|
-
return await formatTsWithPrettier(source);
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
// src/cms/generate/command.ts
|
|
500
|
-
var spinner = createSpinner();
|
|
501
|
-
var cmsGenerateCommand = new Command("generate").description("generate orizm client and types.").option("-c, --config <path>", "orizm config file path.", "orizm.config.ts").option("-o, --output <path>", "output directory.", "./src/orizm").action(async (options) => {
|
|
502
|
-
try {
|
|
503
|
-
spinner.start("Loading project schema...");
|
|
504
|
-
const config = await loadConfig(options.config);
|
|
505
|
-
spinner.succeed("Loaded project schema.");
|
|
506
|
-
spinner.start("Generating code...");
|
|
507
|
-
await generate({
|
|
508
|
-
config,
|
|
509
|
-
output: options.output
|
|
510
|
-
});
|
|
511
|
-
spinner.succeed(`Generated code to '${options.output}'`);
|
|
512
|
-
} catch (error2) {
|
|
513
|
-
handleError(error2);
|
|
514
|
-
}
|
|
515
|
-
});
|
|
516
|
-
|
|
517
|
-
// src/cms/pull/command.ts
|
|
518
|
-
import { Command as Command2 } from "commander";
|
|
519
|
-
|
|
520
|
-
// ../internal-shared/dist/chunk-TTAO2AN2.js
|
|
521
|
-
var PATH_PARAM_RE = /\{[^{}]+\}/g;
|
|
522
|
-
var supportsRequestInitExt = () => {
|
|
523
|
-
return typeof process === "object" && Number.parseInt(process?.versions?.node?.substring(0, 2)) >= 18 && process.versions.undici;
|
|
524
|
-
};
|
|
525
|
-
function randomID() {
|
|
526
|
-
return Math.random().toString(36).slice(2, 11);
|
|
527
|
-
}
|
|
528
|
-
function createClient(clientOptions) {
|
|
529
|
-
let {
|
|
530
|
-
baseUrl = "",
|
|
531
|
-
Request: CustomRequest = globalThis.Request,
|
|
532
|
-
fetch: baseFetch = globalThis.fetch,
|
|
533
|
-
querySerializer: globalQuerySerializer,
|
|
534
|
-
bodySerializer: globalBodySerializer,
|
|
535
|
-
pathSerializer: globalPathSerializer,
|
|
536
|
-
headers: baseHeaders,
|
|
537
|
-
requestInitExt = void 0,
|
|
538
|
-
...baseOptions
|
|
539
|
-
} = { ...clientOptions };
|
|
540
|
-
requestInitExt = supportsRequestInitExt() ? requestInitExt : void 0;
|
|
541
|
-
baseUrl = removeTrailingSlash(baseUrl);
|
|
542
|
-
const globalMiddlewares = [];
|
|
543
|
-
async function coreFetch(schemaPath, fetchOptions) {
|
|
544
|
-
const {
|
|
545
|
-
baseUrl: localBaseUrl,
|
|
546
|
-
fetch = baseFetch,
|
|
547
|
-
Request = CustomRequest,
|
|
548
|
-
headers,
|
|
549
|
-
params = {},
|
|
550
|
-
parseAs = "json",
|
|
551
|
-
querySerializer: requestQuerySerializer,
|
|
552
|
-
bodySerializer = globalBodySerializer ?? defaultBodySerializer,
|
|
553
|
-
pathSerializer: requestPathSerializer,
|
|
554
|
-
body,
|
|
555
|
-
middleware: requestMiddlewares = [],
|
|
556
|
-
...init
|
|
557
|
-
} = fetchOptions || {};
|
|
558
|
-
let finalBaseUrl = baseUrl;
|
|
559
|
-
if (localBaseUrl) {
|
|
560
|
-
finalBaseUrl = removeTrailingSlash(localBaseUrl) ?? baseUrl;
|
|
561
|
-
}
|
|
562
|
-
let querySerializer = typeof globalQuerySerializer === "function" ? globalQuerySerializer : createQuerySerializer(globalQuerySerializer);
|
|
563
|
-
if (requestQuerySerializer) {
|
|
564
|
-
querySerializer = typeof requestQuerySerializer === "function" ? requestQuerySerializer : createQuerySerializer({
|
|
565
|
-
...typeof globalQuerySerializer === "object" ? globalQuerySerializer : {},
|
|
566
|
-
...requestQuerySerializer
|
|
567
|
-
});
|
|
568
|
-
}
|
|
569
|
-
const pathSerializer = requestPathSerializer || globalPathSerializer || defaultPathSerializer;
|
|
570
|
-
const serializedBody = body === void 0 ? void 0 : bodySerializer(
|
|
571
|
-
body,
|
|
572
|
-
// Note: we declare mergeHeaders() both here and below because it’s a bit of a chicken-or-egg situation:
|
|
573
|
-
// bodySerializer() needs all headers so we aren’t dropping ones set by the user, however,
|
|
574
|
-
// the result of this ALSO sets the lowest-priority content-type header. So we re-merge below,
|
|
575
|
-
// setting the content-type at the very beginning to be overwritten.
|
|
576
|
-
// Lastly, based on the way headers work, it’s not a simple “present-or-not” check becauase null intentionally un-sets headers.
|
|
577
|
-
mergeHeaders(baseHeaders, headers, params.header)
|
|
578
|
-
);
|
|
579
|
-
const finalHeaders = mergeHeaders(
|
|
580
|
-
// with no body, we should not to set Content-Type
|
|
581
|
-
serializedBody === void 0 || // if serialized body is FormData; browser will correctly set Content-Type & boundary expression
|
|
582
|
-
serializedBody instanceof FormData ? {} : {
|
|
583
|
-
"Content-Type": "application/json"
|
|
584
|
-
},
|
|
585
|
-
baseHeaders,
|
|
586
|
-
headers,
|
|
587
|
-
params.header
|
|
588
|
-
);
|
|
589
|
-
const finalMiddlewares = [...globalMiddlewares, ...requestMiddlewares];
|
|
590
|
-
const requestInit = {
|
|
591
|
-
redirect: "follow",
|
|
592
|
-
...baseOptions,
|
|
593
|
-
...init,
|
|
594
|
-
body: serializedBody,
|
|
595
|
-
headers: finalHeaders
|
|
596
|
-
};
|
|
597
|
-
let id;
|
|
598
|
-
let options;
|
|
599
|
-
let request = new Request(
|
|
600
|
-
createFinalURL(schemaPath, { baseUrl: finalBaseUrl, params, querySerializer, pathSerializer }),
|
|
601
|
-
requestInit
|
|
602
|
-
);
|
|
603
|
-
let response;
|
|
604
|
-
for (const key in init) {
|
|
605
|
-
if (!(key in request)) {
|
|
606
|
-
request[key] = init[key];
|
|
607
|
-
}
|
|
608
|
-
}
|
|
609
|
-
if (finalMiddlewares.length) {
|
|
610
|
-
id = randomID();
|
|
611
|
-
options = Object.freeze({
|
|
612
|
-
baseUrl: finalBaseUrl,
|
|
613
|
-
fetch,
|
|
614
|
-
parseAs,
|
|
615
|
-
querySerializer,
|
|
616
|
-
bodySerializer,
|
|
617
|
-
pathSerializer
|
|
618
|
-
});
|
|
619
|
-
for (const m of finalMiddlewares) {
|
|
620
|
-
if (m && typeof m === "object" && typeof m.onRequest === "function") {
|
|
621
|
-
const result = await m.onRequest({
|
|
622
|
-
request,
|
|
623
|
-
schemaPath,
|
|
624
|
-
params,
|
|
625
|
-
options,
|
|
626
|
-
id
|
|
627
|
-
});
|
|
628
|
-
if (result) {
|
|
629
|
-
if (result instanceof Request) {
|
|
630
|
-
request = result;
|
|
631
|
-
} else if (result instanceof Response) {
|
|
632
|
-
response = result;
|
|
633
|
-
break;
|
|
634
|
-
} else {
|
|
635
|
-
throw new Error("onRequest: must return new Request() or Response() when modifying the request");
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
}
|
|
640
|
-
}
|
|
641
|
-
if (!response) {
|
|
642
|
-
try {
|
|
643
|
-
response = await fetch(request, requestInitExt);
|
|
644
|
-
} catch (error22) {
|
|
645
|
-
let errorAfterMiddleware = error22;
|
|
646
|
-
if (finalMiddlewares.length) {
|
|
647
|
-
for (let i = finalMiddlewares.length - 1; i >= 0; i--) {
|
|
648
|
-
const m = finalMiddlewares[i];
|
|
649
|
-
if (m && typeof m === "object" && typeof m.onError === "function") {
|
|
650
|
-
const result = await m.onError({
|
|
651
|
-
request,
|
|
652
|
-
error: errorAfterMiddleware,
|
|
653
|
-
schemaPath,
|
|
654
|
-
params,
|
|
655
|
-
options,
|
|
656
|
-
id
|
|
657
|
-
});
|
|
658
|
-
if (result) {
|
|
659
|
-
if (result instanceof Response) {
|
|
660
|
-
errorAfterMiddleware = void 0;
|
|
661
|
-
response = result;
|
|
662
|
-
break;
|
|
663
|
-
}
|
|
664
|
-
if (result instanceof Error) {
|
|
665
|
-
errorAfterMiddleware = result;
|
|
666
|
-
continue;
|
|
667
|
-
}
|
|
668
|
-
throw new Error("onError: must return new Response() or instance of Error");
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
if (errorAfterMiddleware) {
|
|
674
|
-
throw errorAfterMiddleware;
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
if (finalMiddlewares.length) {
|
|
678
|
-
for (let i = finalMiddlewares.length - 1; i >= 0; i--) {
|
|
679
|
-
const m = finalMiddlewares[i];
|
|
680
|
-
if (m && typeof m === "object" && typeof m.onResponse === "function") {
|
|
681
|
-
const result = await m.onResponse({
|
|
682
|
-
request,
|
|
683
|
-
response,
|
|
684
|
-
schemaPath,
|
|
685
|
-
params,
|
|
686
|
-
options,
|
|
687
|
-
id
|
|
688
|
-
});
|
|
689
|
-
if (result) {
|
|
690
|
-
if (!(result instanceof Response)) {
|
|
691
|
-
throw new Error("onResponse: must return new Response() when modifying the response");
|
|
692
|
-
}
|
|
693
|
-
response = result;
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
}
|
|
698
|
-
}
|
|
699
|
-
const contentLength = response.headers.get("Content-Length");
|
|
700
|
-
if (response.status === 204 || request.method === "HEAD" || contentLength === "0" && !response.headers.get("Transfer-Encoding")?.includes("chunked")) {
|
|
701
|
-
return response.ok ? { data: void 0, response } : { error: void 0, response };
|
|
702
|
-
}
|
|
703
|
-
if (response.ok) {
|
|
704
|
-
const getResponseData = async () => {
|
|
705
|
-
if (parseAs === "stream") {
|
|
706
|
-
return response.body;
|
|
707
|
-
}
|
|
708
|
-
if (parseAs === "json" && !contentLength) {
|
|
709
|
-
const raw = await response.text();
|
|
710
|
-
return raw ? JSON.parse(raw) : void 0;
|
|
711
|
-
}
|
|
712
|
-
return await response[parseAs]();
|
|
713
|
-
};
|
|
714
|
-
return { data: await getResponseData(), response };
|
|
715
|
-
}
|
|
716
|
-
let error2 = await response.text();
|
|
717
|
-
try {
|
|
718
|
-
error2 = JSON.parse(error2);
|
|
719
|
-
} catch {
|
|
720
|
-
}
|
|
721
|
-
return { error: error2, response };
|
|
722
|
-
}
|
|
723
|
-
return {
|
|
724
|
-
request(method, url, init) {
|
|
725
|
-
return coreFetch(url, { ...init, method: method.toUpperCase() });
|
|
726
|
-
},
|
|
727
|
-
/** Call a GET endpoint */
|
|
728
|
-
GET(url, init) {
|
|
729
|
-
return coreFetch(url, { ...init, method: "GET" });
|
|
730
|
-
},
|
|
731
|
-
/** Call a PUT endpoint */
|
|
732
|
-
PUT(url, init) {
|
|
733
|
-
return coreFetch(url, { ...init, method: "PUT" });
|
|
734
|
-
},
|
|
735
|
-
/** Call a POST endpoint */
|
|
736
|
-
POST(url, init) {
|
|
737
|
-
return coreFetch(url, { ...init, method: "POST" });
|
|
738
|
-
},
|
|
739
|
-
/** Call a DELETE endpoint */
|
|
740
|
-
DELETE(url, init) {
|
|
741
|
-
return coreFetch(url, { ...init, method: "DELETE" });
|
|
742
|
-
},
|
|
743
|
-
/** Call a OPTIONS endpoint */
|
|
744
|
-
OPTIONS(url, init) {
|
|
745
|
-
return coreFetch(url, { ...init, method: "OPTIONS" });
|
|
746
|
-
},
|
|
747
|
-
/** Call a HEAD endpoint */
|
|
748
|
-
HEAD(url, init) {
|
|
749
|
-
return coreFetch(url, { ...init, method: "HEAD" });
|
|
750
|
-
},
|
|
751
|
-
/** Call a PATCH endpoint */
|
|
752
|
-
PATCH(url, init) {
|
|
753
|
-
return coreFetch(url, { ...init, method: "PATCH" });
|
|
754
|
-
},
|
|
755
|
-
/** Call a TRACE endpoint */
|
|
756
|
-
TRACE(url, init) {
|
|
757
|
-
return coreFetch(url, { ...init, method: "TRACE" });
|
|
758
|
-
},
|
|
759
|
-
/** Register middleware */
|
|
760
|
-
use(...middleware) {
|
|
761
|
-
for (const m of middleware) {
|
|
762
|
-
if (!m) {
|
|
763
|
-
continue;
|
|
764
|
-
}
|
|
765
|
-
if (typeof m !== "object" || !("onRequest" in m || "onResponse" in m || "onError" in m)) {
|
|
766
|
-
throw new Error("Middleware must be an object with one of `onRequest()`, `onResponse() or `onError()`");
|
|
767
|
-
}
|
|
768
|
-
globalMiddlewares.push(m);
|
|
769
|
-
}
|
|
770
|
-
},
|
|
771
|
-
/** Unregister middleware */
|
|
772
|
-
eject(...middleware) {
|
|
773
|
-
for (const m of middleware) {
|
|
774
|
-
const i = globalMiddlewares.indexOf(m);
|
|
775
|
-
if (i !== -1) {
|
|
776
|
-
globalMiddlewares.splice(i, 1);
|
|
777
|
-
}
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
};
|
|
781
|
-
}
|
|
782
|
-
function serializePrimitiveParam(name, value, options) {
|
|
783
|
-
if (value === void 0 || value === null) {
|
|
784
|
-
return "";
|
|
785
|
-
}
|
|
786
|
-
if (typeof value === "object") {
|
|
787
|
-
throw new Error(
|
|
788
|
-
"Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these."
|
|
789
|
-
);
|
|
790
|
-
}
|
|
791
|
-
return `${name}=${options?.allowReserved === true ? value : encodeURIComponent(value)}`;
|
|
792
|
-
}
|
|
793
|
-
function serializeObjectParam(name, value, options) {
|
|
794
|
-
if (!value || typeof value !== "object") {
|
|
795
|
-
return "";
|
|
796
|
-
}
|
|
797
|
-
const values = [];
|
|
798
|
-
const joiner = {
|
|
799
|
-
simple: ",",
|
|
800
|
-
label: ".",
|
|
801
|
-
matrix: ";"
|
|
802
|
-
}[options.style] || "&";
|
|
803
|
-
if (options.style !== "deepObject" && options.explode === false) {
|
|
804
|
-
for (const k in value) {
|
|
805
|
-
values.push(k, options.allowReserved === true ? value[k] : encodeURIComponent(value[k]));
|
|
806
|
-
}
|
|
807
|
-
const final2 = values.join(",");
|
|
808
|
-
switch (options.style) {
|
|
809
|
-
case "form": {
|
|
810
|
-
return `${name}=${final2}`;
|
|
811
|
-
}
|
|
812
|
-
case "label": {
|
|
813
|
-
return `.${final2}`;
|
|
814
|
-
}
|
|
815
|
-
case "matrix": {
|
|
816
|
-
return `;${name}=${final2}`;
|
|
817
|
-
}
|
|
818
|
-
default: {
|
|
819
|
-
return final2;
|
|
820
|
-
}
|
|
821
|
-
}
|
|
822
|
-
}
|
|
823
|
-
for (const k in value) {
|
|
824
|
-
const finalName = options.style === "deepObject" ? `${name}[${k}]` : k;
|
|
825
|
-
values.push(serializePrimitiveParam(finalName, value[k], options));
|
|
826
|
-
}
|
|
827
|
-
const final = values.join(joiner);
|
|
828
|
-
return options.style === "label" || options.style === "matrix" ? `${joiner}${final}` : final;
|
|
829
|
-
}
|
|
830
|
-
function serializeArrayParam(name, value, options) {
|
|
831
|
-
if (!Array.isArray(value)) {
|
|
832
|
-
return "";
|
|
833
|
-
}
|
|
834
|
-
if (options.explode === false) {
|
|
835
|
-
const joiner2 = { form: ",", spaceDelimited: "%20", pipeDelimited: "|" }[options.style] || ",";
|
|
836
|
-
const final = (options.allowReserved === true ? value : value.map((v6) => encodeURIComponent(v6))).join(joiner2);
|
|
837
|
-
switch (options.style) {
|
|
838
|
-
case "simple": {
|
|
839
|
-
return final;
|
|
840
|
-
}
|
|
841
|
-
case "label": {
|
|
842
|
-
return `.${final}`;
|
|
843
|
-
}
|
|
844
|
-
case "matrix": {
|
|
845
|
-
return `;${name}=${final}`;
|
|
846
|
-
}
|
|
847
|
-
// case "spaceDelimited":
|
|
848
|
-
// case "pipeDelimited":
|
|
849
|
-
default: {
|
|
850
|
-
return `${name}=${final}`;
|
|
851
|
-
}
|
|
852
|
-
}
|
|
853
|
-
}
|
|
854
|
-
const joiner = { simple: ",", label: ".", matrix: ";" }[options.style] || "&";
|
|
855
|
-
const values = [];
|
|
856
|
-
for (const v6 of value) {
|
|
857
|
-
if (options.style === "simple" || options.style === "label") {
|
|
858
|
-
values.push(options.allowReserved === true ? v6 : encodeURIComponent(v6));
|
|
859
|
-
} else {
|
|
860
|
-
values.push(serializePrimitiveParam(name, v6, options));
|
|
861
|
-
}
|
|
862
|
-
}
|
|
863
|
-
return options.style === "label" || options.style === "matrix" ? `${joiner}${values.join(joiner)}` : values.join(joiner);
|
|
864
|
-
}
|
|
865
|
-
function createQuerySerializer(options) {
|
|
866
|
-
return function querySerializer(queryParams) {
|
|
867
|
-
const search = [];
|
|
868
|
-
if (queryParams && typeof queryParams === "object") {
|
|
869
|
-
for (const name in queryParams) {
|
|
870
|
-
const value = queryParams[name];
|
|
871
|
-
if (value === void 0 || value === null) {
|
|
872
|
-
continue;
|
|
873
|
-
}
|
|
874
|
-
if (Array.isArray(value)) {
|
|
875
|
-
if (value.length === 0) {
|
|
876
|
-
continue;
|
|
877
|
-
}
|
|
878
|
-
search.push(
|
|
879
|
-
serializeArrayParam(name, value, {
|
|
880
|
-
style: "form",
|
|
881
|
-
explode: true,
|
|
882
|
-
...options?.array,
|
|
883
|
-
allowReserved: options?.allowReserved || false
|
|
884
|
-
})
|
|
885
|
-
);
|
|
886
|
-
continue;
|
|
887
|
-
}
|
|
888
|
-
if (typeof value === "object") {
|
|
889
|
-
search.push(
|
|
890
|
-
serializeObjectParam(name, value, {
|
|
891
|
-
style: "deepObject",
|
|
892
|
-
explode: true,
|
|
893
|
-
...options?.object,
|
|
894
|
-
allowReserved: options?.allowReserved || false
|
|
895
|
-
})
|
|
896
|
-
);
|
|
897
|
-
continue;
|
|
898
|
-
}
|
|
899
|
-
search.push(serializePrimitiveParam(name, value, options));
|
|
900
|
-
}
|
|
901
|
-
}
|
|
902
|
-
return search.join("&");
|
|
903
|
-
};
|
|
904
|
-
}
|
|
905
|
-
function defaultPathSerializer(pathname, pathParams) {
|
|
906
|
-
let nextURL = pathname;
|
|
907
|
-
for (const match of pathname.match(PATH_PARAM_RE) ?? []) {
|
|
908
|
-
let name = match.substring(1, match.length - 1);
|
|
909
|
-
let explode = false;
|
|
910
|
-
let style = "simple";
|
|
911
|
-
if (name.endsWith("*")) {
|
|
912
|
-
explode = true;
|
|
913
|
-
name = name.substring(0, name.length - 1);
|
|
914
|
-
}
|
|
915
|
-
if (name.startsWith(".")) {
|
|
916
|
-
style = "label";
|
|
917
|
-
name = name.substring(1);
|
|
918
|
-
} else if (name.startsWith(";")) {
|
|
919
|
-
style = "matrix";
|
|
920
|
-
name = name.substring(1);
|
|
921
|
-
}
|
|
922
|
-
if (!pathParams || pathParams[name] === void 0 || pathParams[name] === null) {
|
|
923
|
-
continue;
|
|
924
|
-
}
|
|
925
|
-
const value = pathParams[name];
|
|
926
|
-
if (Array.isArray(value)) {
|
|
927
|
-
nextURL = nextURL.replace(match, serializeArrayParam(name, value, { style, explode }));
|
|
928
|
-
continue;
|
|
929
|
-
}
|
|
930
|
-
if (typeof value === "object") {
|
|
931
|
-
nextURL = nextURL.replace(match, serializeObjectParam(name, value, { style, explode }));
|
|
932
|
-
continue;
|
|
933
|
-
}
|
|
934
|
-
if (style === "matrix") {
|
|
935
|
-
nextURL = nextURL.replace(match, `;${serializePrimitiveParam(name, value)}`);
|
|
936
|
-
continue;
|
|
937
|
-
}
|
|
938
|
-
nextURL = nextURL.replace(match, style === "label" ? `.${encodeURIComponent(value)}` : encodeURIComponent(value));
|
|
939
|
-
}
|
|
940
|
-
return nextURL;
|
|
941
|
-
}
|
|
942
|
-
function defaultBodySerializer(body, headers) {
|
|
943
|
-
if (body instanceof FormData) {
|
|
944
|
-
return body;
|
|
945
|
-
}
|
|
946
|
-
if (headers) {
|
|
947
|
-
const contentType = headers.get instanceof Function ? headers.get("Content-Type") ?? headers.get("content-type") : headers["Content-Type"] ?? headers["content-type"];
|
|
948
|
-
if (contentType === "application/x-www-form-urlencoded") {
|
|
949
|
-
return new URLSearchParams(body).toString();
|
|
950
|
-
}
|
|
951
|
-
}
|
|
952
|
-
return JSON.stringify(body);
|
|
953
|
-
}
|
|
954
|
-
function createFinalURL(pathname, options) {
|
|
955
|
-
let finalURL = `${options.baseUrl}${pathname}`;
|
|
956
|
-
if (options.params?.path) {
|
|
957
|
-
finalURL = options.pathSerializer(finalURL, options.params.path);
|
|
958
|
-
}
|
|
959
|
-
let search = options.querySerializer(options.params.query ?? {});
|
|
960
|
-
if (search.startsWith("?")) {
|
|
961
|
-
search = search.substring(1);
|
|
962
|
-
}
|
|
963
|
-
if (search) {
|
|
964
|
-
finalURL += `?${search}`;
|
|
965
|
-
}
|
|
966
|
-
return finalURL;
|
|
967
|
-
}
|
|
968
|
-
function mergeHeaders(...allHeaders) {
|
|
969
|
-
const finalHeaders = new Headers();
|
|
970
|
-
for (const h of allHeaders) {
|
|
971
|
-
if (!h || typeof h !== "object") {
|
|
972
|
-
continue;
|
|
973
|
-
}
|
|
974
|
-
const iterator = h instanceof Headers ? h.entries() : Object.entries(h);
|
|
975
|
-
for (const [k, v6] of iterator) {
|
|
976
|
-
if (v6 === null) {
|
|
977
|
-
finalHeaders.delete(k);
|
|
978
|
-
} else if (Array.isArray(v6)) {
|
|
979
|
-
for (const v22 of v6) {
|
|
980
|
-
finalHeaders.append(k, v22);
|
|
981
|
-
}
|
|
982
|
-
} else if (v6 !== void 0) {
|
|
983
|
-
finalHeaders.set(k, v6);
|
|
984
|
-
}
|
|
985
|
-
}
|
|
986
|
-
}
|
|
987
|
-
return finalHeaders;
|
|
988
|
-
}
|
|
989
|
-
function removeTrailingSlash(url) {
|
|
990
|
-
if (url.endsWith("/")) {
|
|
991
|
-
return url.substring(0, url.length - 1);
|
|
992
|
-
}
|
|
993
|
-
return url;
|
|
994
|
-
}
|
|
995
|
-
function assertValidUrlOrigin(origin) {
|
|
996
|
-
const url = new URL(origin);
|
|
997
|
-
if (url.origin !== origin) {
|
|
998
|
-
throw new Error(`${origin} is not a valid URL origin`);
|
|
999
|
-
}
|
|
1000
|
-
}
|
|
1001
|
-
|
|
1002
|
-
// ../internal-shared/dist/api-clients/dev-v2-api-client.js
|
|
1003
|
-
function createDeveloperAPIv2Client({
|
|
1004
|
-
serverOrigin = "",
|
|
1005
|
-
fetch,
|
|
1006
|
-
headers
|
|
1007
|
-
}) {
|
|
1008
|
-
if (serverOrigin) assertValidUrlOrigin(serverOrigin);
|
|
1009
|
-
return createClient({
|
|
1010
|
-
baseUrl: `${serverOrigin}/api/dev/v2`,
|
|
1011
|
-
fetch,
|
|
1012
|
-
headers
|
|
1013
|
-
});
|
|
1014
|
-
}
|
|
1015
|
-
|
|
1016
|
-
// src/lib/fetch-current-definition.ts
|
|
1017
|
-
async function fetchCurrentDefinition(options) {
|
|
1018
|
-
const client = createDeveloperAPIv2Client({
|
|
1019
|
-
serverOrigin: options.baseUrl,
|
|
1020
|
-
headers: {
|
|
1021
|
-
"x-api-key": options.apiKey
|
|
1022
|
-
}
|
|
1023
|
-
});
|
|
1024
|
-
const abortController = new AbortController();
|
|
1025
|
-
const timeout = setTimeout(() => {
|
|
1026
|
-
abortController.abort();
|
|
1027
|
-
}, 1e4);
|
|
1028
|
-
try {
|
|
1029
|
-
const response = await client.GET(
|
|
1030
|
-
"/projects/{projectName}/definitions/current",
|
|
1031
|
-
{
|
|
1032
|
-
params: { path: { projectName: options.projectName } },
|
|
1033
|
-
signal: abortController.signal
|
|
1034
|
-
}
|
|
1035
|
-
);
|
|
1036
|
-
if (response.data) {
|
|
1037
|
-
return response.data;
|
|
1038
|
-
}
|
|
1039
|
-
if (response.response.status === 404) {
|
|
1040
|
-
throw new Error(`Project ${options.projectName} not found.`);
|
|
1041
|
-
}
|
|
1042
|
-
if (response.response.status === 401) {
|
|
1043
|
-
throw new Error(`API Key is invalid.`);
|
|
1044
|
-
}
|
|
1045
|
-
throw new Error(
|
|
1046
|
-
`Unknown error occurred when fetching definitions for project ${options.projectName}.`
|
|
1047
|
-
);
|
|
1048
|
-
} catch (error2) {
|
|
1049
|
-
if (error2 instanceof Error && error2.name === "AbortError") {
|
|
1050
|
-
throw new Error("Request timed out.");
|
|
1051
|
-
}
|
|
1052
|
-
throw error2;
|
|
1053
|
-
} finally {
|
|
1054
|
-
clearTimeout(timeout);
|
|
1055
|
-
}
|
|
1056
|
-
}
|
|
1057
|
-
|
|
1058
|
-
// src/lib/load-env.ts
|
|
1059
|
-
import fs from "fs/promises";
|
|
1060
|
-
import * as v4 from "valibot";
|
|
1061
|
-
import dotenv from "dotenv";
|
|
1062
|
-
var DEFAULT_ENV_FILE_PATH = ".env";
|
|
1063
|
-
var EnvSchema = v4.object({
|
|
1064
|
-
ORIZM_PROJECT: v4.pipe(
|
|
1065
|
-
v4.string(),
|
|
1066
|
-
v4.minLength(1, "ORIZM_PROJECT is required"),
|
|
1067
|
-
v4.brand("ORIZM_PROJECT")
|
|
1068
|
-
),
|
|
1069
|
-
ORIZM_BASE_URL: v4.pipe(
|
|
1070
|
-
v4.optional(v4.string(), "https://app.orizm.com"),
|
|
1071
|
-
// if null, use default value
|
|
1072
|
-
v4.transform((v6) => v6.replace(/\/$/, "")),
|
|
1073
|
-
// remove trailing slash
|
|
1074
|
-
v4.brand("ORIZM_BASE_URL")
|
|
1075
|
-
),
|
|
1076
|
-
ORIZM_API_KEY: v4.pipe(
|
|
1077
|
-
v4.string(),
|
|
1078
|
-
v4.minLength(1, "ORIZM_API_KEY is required"),
|
|
1079
|
-
v4.brand("ORIZM_API_KEY")
|
|
1080
|
-
)
|
|
1081
|
-
});
|
|
1082
|
-
async function loadEnv(envPath) {
|
|
1083
|
-
let envFileContent;
|
|
1084
|
-
if (envPath) {
|
|
1085
|
-
envFileContent = await fs.readFile(envPath, "utf-8").catch(() => null);
|
|
1086
|
-
if (!envFileContent) {
|
|
1087
|
-
throw new Error(`Environment variables file: '${envPath}' is not found.`);
|
|
1088
|
-
}
|
|
1089
|
-
} else {
|
|
1090
|
-
envFileContent = await fs.readFile(DEFAULT_ENV_FILE_PATH, "utf-8").catch(() => null);
|
|
1091
|
-
}
|
|
1092
|
-
if (envFileContent !== null) {
|
|
1093
|
-
const dotenvParsed = dotenv.parse(envFileContent);
|
|
1094
|
-
const envParseResult = v4.safeParse(EnvSchema, dotenvParsed);
|
|
1095
|
-
if (!envParseResult.success) {
|
|
1096
|
-
throw new Error(
|
|
1097
|
-
`Environment variables are not valid.
|
|
1098
|
-
` + envParseResult.issues.map((issue) => issue.message).join("\n")
|
|
1099
|
-
);
|
|
1100
|
-
}
|
|
1101
|
-
return envParseResult.output;
|
|
1102
|
-
}
|
|
1103
|
-
const processEnvParseResult = v4.safeParse(EnvSchema, process.env);
|
|
1104
|
-
if (!processEnvParseResult.success) {
|
|
1105
|
-
throw new Error(
|
|
1106
|
-
"Environment variables are not valid. Put .env file or set environment variables in process.env.\n" + processEnvParseResult.issues.map((issue) => issue.message).join("\n")
|
|
1107
|
-
);
|
|
1108
|
-
}
|
|
1109
|
-
return processEnvParseResult.output;
|
|
1110
|
-
}
|
|
1111
|
-
|
|
1112
|
-
// src/cms/pull/action.ts
|
|
1113
|
-
var spinner2 = createSpinner();
|
|
1114
|
-
async function pullAction(options) {
|
|
1115
|
-
spinner2.start("Loading environment variables...");
|
|
1116
|
-
const env = await loadEnv(options.envPath);
|
|
1117
|
-
spinner2.succeed("Loaded environment variables.");
|
|
1118
|
-
spinner2.start("Loading project config...");
|
|
1119
|
-
const definitionReference = await fetchCurrentDefinition({
|
|
1120
|
-
baseUrl: env.ORIZM_BASE_URL,
|
|
1121
|
-
apiKey: env.ORIZM_API_KEY,
|
|
1122
|
-
projectName: env.ORIZM_PROJECT
|
|
1123
|
-
});
|
|
1124
|
-
spinner2.succeed("Loaded project config.");
|
|
1125
|
-
spinner2.start("Generating code...");
|
|
1126
|
-
await generate({
|
|
1127
|
-
output: options.destination,
|
|
1128
|
-
config: definitionReference.parsed
|
|
1129
|
-
});
|
|
1130
|
-
spinner2.succeed(`Generated code to '${options.destination}'`);
|
|
1131
|
-
}
|
|
1132
|
-
|
|
1133
|
-
// src/cms/pull/command.ts
|
|
1134
|
-
var cmsPullCommand = new Command2("pull").description("pull orizm schema and generate client and types.").option("-e, --env [path]", "env file path.").option("-o, --output <path>", "output directory.", "./src/orizm").action(async (options) => {
|
|
1135
|
-
try {
|
|
1136
|
-
await pullAction({
|
|
1137
|
-
destination: options.output,
|
|
1138
|
-
envPath: options.env
|
|
1139
|
-
});
|
|
1140
|
-
} catch (error2) {
|
|
1141
|
-
handleError(error2);
|
|
1142
|
-
}
|
|
1143
|
-
});
|
|
1144
|
-
|
|
1145
|
-
// src/consumer/generate/command.ts
|
|
1146
|
-
import { Command as Command3 } from "commander";
|
|
1147
|
-
|
|
1148
|
-
// src/consumer/pull/generate.ts
|
|
1149
|
-
import { mkdir as mkdir2, writeFile as writeFile2 } from "fs/promises";
|
|
1150
|
-
import path2 from "path";
|
|
1151
|
-
async function generate2(options) {
|
|
1152
|
-
await mkdir2(options.output, { recursive: true });
|
|
1153
|
-
const renderedTypes = await renderTypes2(options.definition);
|
|
1154
|
-
const targetTypesPath = path2.join(options.output, "types.ts");
|
|
1155
|
-
await writeFile2(targetTypesPath, renderedTypes, "utf-8");
|
|
1156
|
-
const renderedClient = await renderClient2(options.definition);
|
|
1157
|
-
const targetClientPath = path2.join(options.output, "client.ts");
|
|
1158
|
-
await writeFile2(targetClientPath, renderedClient, "utf-8");
|
|
1159
|
-
}
|
|
1160
|
-
async function renderTypes2(config) {
|
|
1161
|
-
const tables = config.tables;
|
|
1162
|
-
const modules = config.tableModules ?? [];
|
|
1163
|
-
const source = [
|
|
1164
|
-
renderPreamble("@orizm/consumer-sdk/common"),
|
|
1165
|
-
renderSection("Tables", tables.map(renderTableRowType)),
|
|
1166
|
-
modules.map(renderModuleRowTypeBlock).join("\n\n"),
|
|
1167
|
-
renderSection("Descriptor types", [
|
|
1168
|
-
...tables.map(renderTableDescriptor2),
|
|
1169
|
-
...modules.map(renderModuleDescriptorBlock)
|
|
1170
|
-
]),
|
|
1171
|
-
renderWebhookTypesSection(tables)
|
|
1172
|
-
].filter(Boolean).join("\n\n\n");
|
|
1173
|
-
return await formatTsWithPrettier(source);
|
|
1174
|
-
}
|
|
1175
|
-
function renderTableRowType(table) {
|
|
1176
|
-
return renderTypeBlock(toCodeTypeName(table.name), [
|
|
1177
|
-
"id: string;",
|
|
1178
|
-
"createdAt: string;",
|
|
1179
|
-
"updatedAt: string;",
|
|
1180
|
-
"group: string | null;",
|
|
1181
|
-
"publishedAt: string | null;",
|
|
1182
|
-
"_draft: boolean | null;",
|
|
1183
|
-
"_published: boolean | null;",
|
|
1184
|
-
...table.columns.map((col) => renderColumnField(col)),
|
|
1185
|
-
...table.enableForm ? ["formSchema: FormValidationRules;"] : []
|
|
1186
|
-
]);
|
|
1187
|
-
}
|
|
1188
|
-
function renderTableDescriptor2(table) {
|
|
1189
|
-
const name = toCodeTypeName(table.name);
|
|
1190
|
-
return renderTypeBlock(`${name}__Descriptor`, [
|
|
1191
|
-
`row: ${name};`,
|
|
1192
|
-
...renderRefsFieldLines(table.columns),
|
|
1193
|
-
...renderUniqueFieldLines(table),
|
|
1194
|
-
...table.enableDrafts ? ["enableDrafts: true;"] : []
|
|
1195
|
-
]);
|
|
1196
|
-
}
|
|
1197
|
-
async function renderClient2(config) {
|
|
1198
|
-
const tableEntries = config.tables.map(
|
|
1199
|
-
(t) => `${t.name}: this.getTableClient<Models.${toCodeTypeName(t.name)}__Descriptor>("${t.name}"),`
|
|
1200
|
-
).join("\n");
|
|
1201
|
-
const source = `// This file was automatically generated and should not be edited.
|
|
1202
|
-
|
|
1203
|
-
import { ConsumerClientOptions, OrizmConsumerClientBase } from "@orizm/consumer-sdk";
|
|
1204
|
-
import * as Models from "./types";
|
|
1205
|
-
|
|
1206
|
-
export class OrizmClient extends OrizmConsumerClientBase {
|
|
1207
|
-
constructor(options: ConsumerClientOptions) {
|
|
1208
|
-
super(options);
|
|
1209
|
-
}
|
|
1210
|
-
|
|
1211
|
-
readonly tables = {
|
|
1212
|
-
${tableEntries}
|
|
1213
|
-
};
|
|
1214
|
-
}
|
|
1215
|
-
`;
|
|
1216
|
-
return await formatTsWithPrettier(source);
|
|
1217
|
-
}
|
|
1218
|
-
|
|
1219
|
-
// src/consumer/generate/action.ts
|
|
1220
|
-
var spinner3 = createSpinner();
|
|
1221
|
-
async function generateAction(orizmConfigTs, destination) {
|
|
1222
|
-
spinner3.start("Loading project config...");
|
|
1223
|
-
const definition = await loadConfig(orizmConfigTs);
|
|
1224
|
-
spinner3.succeed("Loaded project config.");
|
|
1225
|
-
spinner3.start("Generating code...");
|
|
1226
|
-
await generate2({
|
|
1227
|
-
definition,
|
|
1228
|
-
output: destination
|
|
1229
|
-
});
|
|
1230
|
-
spinner3.succeed(`Generated code to '${destination}'`);
|
|
1231
|
-
}
|
|
1232
|
-
|
|
1233
|
-
// src/consumer/generate/command.ts
|
|
1234
|
-
var consumerGenerateCommand = new Command3("generate").description("generate orizm client and types.").option("-c, --config <path>", "orizm config file path.", "orizm.config.ts").option("-o, --output <path>", "output directory.", "./src/orizm").action(async (options) => {
|
|
1235
|
-
try {
|
|
1236
|
-
await generateAction(options.config, options.output);
|
|
1237
|
-
} catch (error2) {
|
|
1238
|
-
handleError(error2);
|
|
1239
|
-
}
|
|
1240
|
-
});
|
|
1241
|
-
|
|
1242
|
-
// src/consumer/pull/command.ts
|
|
1243
|
-
import { Command as Command4 } from "commander";
|
|
1244
|
-
|
|
1245
|
-
// src/consumer/pull/action.ts
|
|
1246
|
-
var spinner4 = createSpinner();
|
|
1247
|
-
async function pullAction2(options) {
|
|
1248
|
-
spinner4.start("Loading environment variables...");
|
|
1249
|
-
const config = await loadEnv(options.envPath);
|
|
1250
|
-
spinner4.succeed("Loaded environment variables.");
|
|
1251
|
-
spinner4.start("Loading project config...");
|
|
1252
|
-
const definition = await fetchCurrentDefinition({
|
|
1253
|
-
baseUrl: config.ORIZM_BASE_URL,
|
|
1254
|
-
apiKey: config.ORIZM_API_KEY,
|
|
1255
|
-
projectName: config.ORIZM_PROJECT
|
|
1256
|
-
});
|
|
1257
|
-
spinner4.succeed("Loaded project config.");
|
|
1258
|
-
spinner4.start("Generating code...");
|
|
1259
|
-
await generate2({
|
|
1260
|
-
definition: definition.parsed,
|
|
1261
|
-
output: options.destination
|
|
1262
|
-
});
|
|
1263
|
-
spinner4.succeed(`Generated code to '${options.destination}'`);
|
|
1264
|
-
}
|
|
1265
|
-
|
|
1266
|
-
// src/consumer/pull/command.ts
|
|
1267
|
-
var consumerPullCommand = new Command4("pull").description("pull orizm schema and generate client and types.").option("-e, --env [path]", "env file path.").option("-o, --output <path>", "output directory.", "./src/orizm").action(async (options) => {
|
|
1268
|
-
try {
|
|
1269
|
-
await pullAction2({
|
|
1270
|
-
destination: options.output,
|
|
1271
|
-
envPath: options.env
|
|
1272
|
-
});
|
|
1273
|
-
} catch (error2) {
|
|
1274
|
-
handleError(error2);
|
|
1275
|
-
}
|
|
1276
|
-
});
|
|
1277
|
-
|
|
1278
|
-
// src/push/command.ts
|
|
1279
|
-
import { Command as Command5 } from "commander";
|
|
1280
|
-
import chalk6 from "chalk";
|
|
1281
|
-
|
|
1282
|
-
// src/lib/developer-api.ts
|
|
1283
|
-
import chalk4 from "chalk";
|
|
1284
|
-
async function applyDefinition(env, projectDef) {
|
|
1285
|
-
const client = createDeveloperAPIv2Client({
|
|
1286
|
-
serverOrigin: env.ORIZM_BASE_URL,
|
|
1287
|
-
headers: {
|
|
1288
|
-
"x-api-key": env.ORIZM_API_KEY
|
|
1289
|
-
}
|
|
1290
|
-
});
|
|
1291
|
-
const response = await client.POST("/projects/{projectName}/definitions", {
|
|
1292
|
-
params: { path: { projectName: env.ORIZM_PROJECT } },
|
|
1293
|
-
body: { definition: projectDef }
|
|
1294
|
-
});
|
|
1295
|
-
if (!response.data) {
|
|
1296
|
-
const status = response.response.status;
|
|
1297
|
-
if (status === 401) {
|
|
1298
|
-
throw new Error(
|
|
1299
|
-
"401 Unauthorized. Please check your Developer API key and try again."
|
|
1300
|
-
);
|
|
1301
|
-
}
|
|
1302
|
-
if (response.error.type === "bad-request") {
|
|
1303
|
-
console.log(chalk4.red(response.error.detail));
|
|
1304
|
-
process.exit(1);
|
|
1305
|
-
}
|
|
1306
|
-
throw new Error(
|
|
1307
|
-
`${status} ${response.response.statusText}: Unexpected error occurred while applying schema.`
|
|
1308
|
-
);
|
|
1309
|
-
}
|
|
1310
|
-
}
|
|
1311
|
-
var getChangeEvents = async (env, projectDef) => {
|
|
1312
|
-
const client = createDeveloperAPIv2Client({
|
|
1313
|
-
serverOrigin: env.ORIZM_BASE_URL,
|
|
1314
|
-
headers: {
|
|
1315
|
-
"x-api-key": env.ORIZM_API_KEY
|
|
1316
|
-
}
|
|
1317
|
-
});
|
|
1318
|
-
const response = await client.POST(
|
|
1319
|
-
"/projects/{projectName}/definitions/dry-run",
|
|
1320
|
-
{
|
|
1321
|
-
params: { path: { projectName: env.ORIZM_PROJECT } },
|
|
1322
|
-
body: { definition: projectDef }
|
|
1323
|
-
}
|
|
1324
|
-
);
|
|
1325
|
-
if (!response.data) {
|
|
1326
|
-
const status = response.response.status;
|
|
1327
|
-
if (status === 401) {
|
|
1328
|
-
throw new Error(
|
|
1329
|
-
"401 Unauthorized. Please check your Developer API key and try again."
|
|
1330
|
-
);
|
|
1331
|
-
}
|
|
1332
|
-
throw new Error(
|
|
1333
|
-
`${status} ${response.response.statusText}: Unexpected error occurred while fetching schema change events.
|
|
1334
|
-
${JSON.stringify(response.error, null, 2)}`
|
|
1335
|
-
);
|
|
1336
|
-
}
|
|
1337
|
-
return response.data;
|
|
1338
|
-
};
|
|
1339
|
-
|
|
1340
|
-
// src/lib/display-change-events.ts
|
|
1341
|
-
import chalk5 from "chalk";
|
|
1342
|
-
|
|
1343
|
-
// src/lib/cli-table.ts
|
|
1344
|
-
var COLORS = {
|
|
1345
|
-
reset: "\x1B[0m",
|
|
1346
|
-
green: "\x1B[32m",
|
|
1347
|
-
red: "\x1B[31m"
|
|
1348
|
-
};
|
|
1349
|
-
var CliTable = class {
|
|
1350
|
-
headers = [];
|
|
1351
|
-
rows = [];
|
|
1352
|
-
columnWidths = [];
|
|
1353
|
-
rowColors = [];
|
|
1354
|
-
// 各行の色を保持する配列
|
|
1355
|
-
constructor(headers) {
|
|
1356
|
-
this.headers = headers;
|
|
1357
|
-
this.updateColumnWidths(headers);
|
|
1358
|
-
}
|
|
1359
|
-
// データ行を追加
|
|
1360
|
-
addRow(row, options) {
|
|
1361
|
-
if (row.length !== this.headers.length) {
|
|
1362
|
-
throw new Error(
|
|
1363
|
-
`The length of the row (${row.length}) does not match the length of the header (${this.headers.length})`
|
|
1364
|
-
);
|
|
1365
|
-
}
|
|
1366
|
-
this.rows.push(row);
|
|
1367
|
-
if (options?.color) {
|
|
1368
|
-
this.rowColors.push(COLORS[options.color]);
|
|
1369
|
-
} else {
|
|
1370
|
-
this.rowColors.push(null);
|
|
1371
|
-
}
|
|
1372
|
-
this.updateColumnWidths(row);
|
|
1373
|
-
}
|
|
1374
|
-
// 列幅を更新
|
|
1375
|
-
updateColumnWidths(row) {
|
|
1376
|
-
for (let i = 0; i < row.length; i++) {
|
|
1377
|
-
const cellLength = row[i].length;
|
|
1378
|
-
if (this.columnWidths[i] == null || cellLength > this.columnWidths[i]) {
|
|
1379
|
-
this.columnWidths[i] = cellLength;
|
|
1380
|
-
}
|
|
1381
|
-
}
|
|
1382
|
-
}
|
|
1383
|
-
// 水平線を生成
|
|
1384
|
-
createHorizontalLine(position) {
|
|
1385
|
-
let line = "";
|
|
1386
|
-
if (position === "top") line += "\u250C";
|
|
1387
|
-
else if (position === "middle") line += "\u251C";
|
|
1388
|
-
else if (position === "bottom") line += "\u2514";
|
|
1389
|
-
for (let i = 0; i < this.columnWidths.length; i++) {
|
|
1390
|
-
line += "\u2500".repeat(this.columnWidths[i] + 2);
|
|
1391
|
-
if (i < this.columnWidths.length - 1) {
|
|
1392
|
-
if (position === "top") line += "\u252C";
|
|
1393
|
-
else if (position === "middle") line += "\u253C";
|
|
1394
|
-
else if (position === "bottom") line += "\u2534";
|
|
1395
|
-
} else {
|
|
1396
|
-
if (position === "top") line += "\u2510";
|
|
1397
|
-
else if (position === "middle") line += "\u2524";
|
|
1398
|
-
else if (position === "bottom") line += "\u2518";
|
|
1399
|
-
}
|
|
1400
|
-
}
|
|
1401
|
-
return line;
|
|
1402
|
-
}
|
|
1403
|
-
// 行を整形
|
|
1404
|
-
formatRow(row, color) {
|
|
1405
|
-
let formattedRow = "\u2502";
|
|
1406
|
-
for (let i = 0; i < row.length; i++) {
|
|
1407
|
-
const cell = row[i];
|
|
1408
|
-
const padding = " ".repeat(this.columnWidths[i] - cell.length);
|
|
1409
|
-
if (color) {
|
|
1410
|
-
formattedRow += ` ${color}${cell}${COLORS.reset}${padding} \u2502`;
|
|
1411
|
-
} else {
|
|
1412
|
-
formattedRow += ` ${cell}${padding} \u2502`;
|
|
1413
|
-
}
|
|
1414
|
-
}
|
|
1415
|
-
return formattedRow;
|
|
1416
|
-
}
|
|
1417
|
-
// テーブルを文字列として取得
|
|
1418
|
-
toString() {
|
|
1419
|
-
if (this.headers.length === 0) {
|
|
1420
|
-
return "";
|
|
1421
|
-
}
|
|
1422
|
-
const topLine = this.createHorizontalLine("top");
|
|
1423
|
-
const middleLine = this.createHorizontalLine("middle");
|
|
1424
|
-
const bottomLine = this.createHorizontalLine("bottom");
|
|
1425
|
-
let table = topLine + "\n";
|
|
1426
|
-
table += this.formatRow(this.headers, null) + "\n";
|
|
1427
|
-
table += middleLine + "\n";
|
|
1428
|
-
for (let i = 0; i < this.rows.length; i++) {
|
|
1429
|
-
const color = this.rowColors[i] || null;
|
|
1430
|
-
table += this.formatRow(this.rows[i], color) + "\n";
|
|
1431
|
-
}
|
|
1432
|
-
table += bottomLine;
|
|
1433
|
-
return table;
|
|
1434
|
-
}
|
|
1435
|
-
// テーブルを出力
|
|
1436
|
-
print() {
|
|
1437
|
-
console.log(this.toString());
|
|
1438
|
-
}
|
|
1439
|
-
};
|
|
1440
|
-
|
|
1441
|
-
// src/lib/display-change-events.ts
|
|
1442
|
-
function displayChangeEvents(changeEvents) {
|
|
1443
|
-
const {
|
|
1444
|
-
tableChangeEvents = [],
|
|
1445
|
-
bucketChangeEvents = [],
|
|
1446
|
-
authorityChangeEvents = []
|
|
1447
|
-
} = changeEvents;
|
|
1448
|
-
if (tableChangeEvents.length === 0 && bucketChangeEvents.length === 0 && authorityChangeEvents.length === 0) {
|
|
1449
|
-
console.log();
|
|
1450
|
-
console.log(chalk5.green("No changes."));
|
|
1451
|
-
return;
|
|
1452
|
-
}
|
|
1453
|
-
displayTableChangeEvents(tableChangeEvents);
|
|
1454
|
-
displayBucketChangeEvents(bucketChangeEvents);
|
|
1455
|
-
displayAuthorityChangeEvents(authorityChangeEvents);
|
|
1456
|
-
console.log();
|
|
1457
|
-
}
|
|
1458
|
-
function displayTableChangeEvents(tableChangeEvents) {
|
|
1459
|
-
if (tableChangeEvents.length === 0) {
|
|
1460
|
-
return;
|
|
1461
|
-
}
|
|
1462
|
-
const eventsByTable = /* @__PURE__ */ new Map();
|
|
1463
|
-
for (const event of tableChangeEvents) {
|
|
1464
|
-
const tableName = event.tableDef.name;
|
|
1465
|
-
const tableEvents = eventsByTable.get(tableName) ?? [];
|
|
1466
|
-
tableEvents.push(event);
|
|
1467
|
-
eventsByTable.set(tableName, tableEvents);
|
|
1468
|
-
}
|
|
1469
|
-
for (const [tableName, events] of eventsByTable.entries()) {
|
|
1470
|
-
console.log();
|
|
1471
|
-
console.log(`\u26AB\uFE0ETable: ${tableName}`);
|
|
1472
|
-
const table = new CliTable(["Type", "Name", "Event", "Detail"]);
|
|
1473
|
-
for (const event of events) {
|
|
1474
|
-
const eventName = event.event;
|
|
1475
|
-
switch (eventName) {
|
|
1476
|
-
case "table:create":
|
|
1477
|
-
case "table:update": {
|
|
1478
|
-
table.addRow(["table", event.tableDef.name, eventName, ""], {
|
|
1479
|
-
color: "green"
|
|
1480
|
-
});
|
|
1481
|
-
break;
|
|
1482
|
-
}
|
|
1483
|
-
case "table:delete": {
|
|
1484
|
-
table.addRow(["table", event.tableDef.name, eventName, ""], {
|
|
1485
|
-
color: "red"
|
|
1486
|
-
});
|
|
1487
|
-
break;
|
|
1488
|
-
}
|
|
1489
|
-
case "column:create":
|
|
1490
|
-
case "column:update": {
|
|
1491
|
-
table.addRow(
|
|
1492
|
-
[
|
|
1493
|
-
"column",
|
|
1494
|
-
event.columnDef.name,
|
|
1495
|
-
eventName,
|
|
1496
|
-
JSON.stringify(event.columnDef)
|
|
1497
|
-
],
|
|
1498
|
-
{ color: "green" }
|
|
1499
|
-
);
|
|
1500
|
-
break;
|
|
1501
|
-
}
|
|
1502
|
-
case "column:delete": {
|
|
1503
|
-
table.addRow(
|
|
1504
|
-
[
|
|
1505
|
-
"column",
|
|
1506
|
-
event.columnDef.name,
|
|
1507
|
-
eventName,
|
|
1508
|
-
JSON.stringify(event.columnDef)
|
|
1509
|
-
],
|
|
1510
|
-
{
|
|
1511
|
-
color: "red"
|
|
1512
|
-
}
|
|
1513
|
-
);
|
|
1514
|
-
break;
|
|
1515
|
-
}
|
|
1516
|
-
case "index:create":
|
|
1517
|
-
case "index:update": {
|
|
1518
|
-
table.addRow(
|
|
1519
|
-
[
|
|
1520
|
-
"index",
|
|
1521
|
-
event.indexDef.columns.join(", "),
|
|
1522
|
-
eventName,
|
|
1523
|
-
JSON.stringify(event.indexDef)
|
|
1524
|
-
],
|
|
1525
|
-
{ color: "green" }
|
|
1526
|
-
);
|
|
1527
|
-
break;
|
|
1528
|
-
}
|
|
1529
|
-
case "index:delete": {
|
|
1530
|
-
table.addRow(
|
|
1531
|
-
[
|
|
1532
|
-
"index",
|
|
1533
|
-
event.indexDef.columns.join(", "),
|
|
1534
|
-
eventName,
|
|
1535
|
-
JSON.stringify(event.indexDef)
|
|
1536
|
-
],
|
|
1537
|
-
{ color: "red" }
|
|
1538
|
-
);
|
|
1539
|
-
break;
|
|
1540
|
-
}
|
|
1541
|
-
case "module:create":
|
|
1542
|
-
case "module:update": {
|
|
1543
|
-
table.addRow(
|
|
1544
|
-
[
|
|
1545
|
-
"module",
|
|
1546
|
-
event.columnDef.name,
|
|
1547
|
-
eventName,
|
|
1548
|
-
JSON.stringify(event.columnDef)
|
|
1549
|
-
],
|
|
1550
|
-
{
|
|
1551
|
-
color: "green"
|
|
1552
|
-
}
|
|
1553
|
-
);
|
|
1554
|
-
break;
|
|
1555
|
-
}
|
|
1556
|
-
case "module:delete": {
|
|
1557
|
-
table.addRow(
|
|
1558
|
-
[
|
|
1559
|
-
"module",
|
|
1560
|
-
event.columnDef.name,
|
|
1561
|
-
eventName,
|
|
1562
|
-
JSON.stringify(event.columnDef)
|
|
1563
|
-
],
|
|
1564
|
-
{
|
|
1565
|
-
color: "red"
|
|
1566
|
-
}
|
|
1567
|
-
);
|
|
1568
|
-
break;
|
|
1569
|
-
}
|
|
1570
|
-
case "search:enable":
|
|
1571
|
-
case "search:update": {
|
|
1572
|
-
table.addRow(["table", event.tableDef.name, eventName, ""], {
|
|
1573
|
-
color: "green"
|
|
1574
|
-
});
|
|
1575
|
-
break;
|
|
1576
|
-
}
|
|
1577
|
-
case "search:disable": {
|
|
1578
|
-
table.addRow(["table", event.tableDef.name, eventName, ""], {
|
|
1579
|
-
color: "red"
|
|
1580
|
-
});
|
|
1581
|
-
break;
|
|
1582
|
-
}
|
|
1583
|
-
case "history:enable": {
|
|
1584
|
-
table.addRow(["table", event.tableDef.name, eventName, ""], {
|
|
1585
|
-
color: "green"
|
|
1586
|
-
});
|
|
1587
|
-
break;
|
|
1588
|
-
}
|
|
1589
|
-
case "history:disable": {
|
|
1590
|
-
table.addRow(["table", event.tableDef.name, eventName, ""], {
|
|
1591
|
-
color: "red"
|
|
1592
|
-
});
|
|
1593
|
-
break;
|
|
1594
|
-
}
|
|
1595
|
-
case "draft:enable": {
|
|
1596
|
-
table.addRow(["table", event.tableDef.name, eventName, ""], {
|
|
1597
|
-
color: "green"
|
|
1598
|
-
});
|
|
1599
|
-
break;
|
|
1600
|
-
}
|
|
1601
|
-
case "draft:disable": {
|
|
1602
|
-
table.addRow(["table", event.tableDef.name, eventName, ""], {
|
|
1603
|
-
color: "red"
|
|
1604
|
-
});
|
|
1605
|
-
break;
|
|
1606
|
-
}
|
|
1607
|
-
case "formSubmissions:create":
|
|
1608
|
-
case "formSubmissions:update": {
|
|
1609
|
-
table.addRow(["table", event.tableDef.name, eventName, ""], {
|
|
1610
|
-
color: "green"
|
|
1611
|
-
});
|
|
1612
|
-
break;
|
|
1613
|
-
}
|
|
1614
|
-
case "formSubmissions:delete": {
|
|
1615
|
-
table.addRow(["table", event.tableDef.name, eventName, ""], {
|
|
1616
|
-
color: "red"
|
|
1617
|
-
});
|
|
1618
|
-
break;
|
|
1619
|
-
}
|
|
1620
|
-
}
|
|
1621
|
-
}
|
|
1622
|
-
table.print();
|
|
1623
|
-
}
|
|
1624
|
-
}
|
|
1625
|
-
function displayBucketChangeEvents(bucketChangeEvents) {
|
|
1626
|
-
if (bucketChangeEvents.length === 0) {
|
|
1627
|
-
return;
|
|
1628
|
-
}
|
|
1629
|
-
const eventsByBucket = /* @__PURE__ */ new Map();
|
|
1630
|
-
for (const event of bucketChangeEvents) {
|
|
1631
|
-
const bucketName = event.bucketDef.name;
|
|
1632
|
-
const bucketEvents = eventsByBucket.get(bucketName) ?? [];
|
|
1633
|
-
bucketEvents.push(event);
|
|
1634
|
-
eventsByBucket.set(bucketName, bucketEvents);
|
|
1635
|
-
}
|
|
1636
|
-
const table = new CliTable(["Type", "Name", "Event", "Detail"]);
|
|
1637
|
-
console.log();
|
|
1638
|
-
console.log("\u26AB\uFE0EBuckets");
|
|
1639
|
-
for (const [_, events] of eventsByBucket.entries()) {
|
|
1640
|
-
for (const event of events) {
|
|
1641
|
-
const eventName = event.event;
|
|
1642
|
-
switch (eventName) {
|
|
1643
|
-
case "bucket:create":
|
|
1644
|
-
case "bucket:update": {
|
|
1645
|
-
table.addRow(
|
|
1646
|
-
[
|
|
1647
|
-
"bucket",
|
|
1648
|
-
event.bucketDef.name,
|
|
1649
|
-
eventName,
|
|
1650
|
-
JSON.stringify(event.bucketDef)
|
|
1651
|
-
],
|
|
1652
|
-
{
|
|
1653
|
-
color: "green"
|
|
1654
|
-
}
|
|
1655
|
-
);
|
|
1656
|
-
break;
|
|
1657
|
-
}
|
|
1658
|
-
case "bucket:delete": {
|
|
1659
|
-
table.addRow(
|
|
1660
|
-
[
|
|
1661
|
-
"bucket",
|
|
1662
|
-
event.bucketDef.name,
|
|
1663
|
-
eventName,
|
|
1664
|
-
JSON.stringify(event.bucketDef)
|
|
1665
|
-
],
|
|
1666
|
-
{
|
|
1667
|
-
color: "red"
|
|
1668
|
-
}
|
|
1669
|
-
);
|
|
1670
|
-
break;
|
|
1671
|
-
}
|
|
1672
|
-
}
|
|
1673
|
-
}
|
|
1674
|
-
}
|
|
1675
|
-
table.print();
|
|
1676
|
-
}
|
|
1677
|
-
function displayAuthorityChangeEvents(authorityChangeEvents) {
|
|
1678
|
-
if (authorityChangeEvents.length === 0) {
|
|
1679
|
-
return;
|
|
1680
|
-
}
|
|
1681
|
-
const table = new CliTable(["Type", "Event", "Detail"]);
|
|
1682
|
-
console.log();
|
|
1683
|
-
console.log("\u26AB\uFE0EAuthorities");
|
|
1684
|
-
for (const event of authorityChangeEvents) {
|
|
1685
|
-
const eventName = event.event;
|
|
1686
|
-
switch (eventName) {
|
|
1687
|
-
case "authority:update": {
|
|
1688
|
-
table.addRow(
|
|
1689
|
-
["authority", eventName, JSON.stringify(event.authorityDef)],
|
|
1690
|
-
{ color: "green" }
|
|
1691
|
-
);
|
|
1692
|
-
break;
|
|
1693
|
-
}
|
|
1694
|
-
}
|
|
1695
|
-
}
|
|
1696
|
-
table.print();
|
|
1697
|
-
}
|
|
1698
|
-
|
|
1699
|
-
// src/lib/cli-input.ts
|
|
1700
|
-
import { createInterface } from "readline/promises";
|
|
1701
|
-
async function input(prompt) {
|
|
1702
|
-
const rl = createInterface({
|
|
1703
|
-
input: process.stdin,
|
|
1704
|
-
output: process.stdout
|
|
1705
|
-
});
|
|
1706
|
-
const input2 = await rl.question(prompt).finally(() => {
|
|
1707
|
-
rl.close();
|
|
1708
|
-
});
|
|
1709
|
-
return input2.trim();
|
|
1710
|
-
}
|
|
1711
|
-
|
|
1712
|
-
// src/push/command.ts
|
|
1713
|
-
var spinner5 = createSpinner();
|
|
1714
|
-
var pushCommand = new Command5("push").description("apply schema to project.").option("-e, --env <path>", "env file path.").option("-c, --config <path>", "orizm config file path.", "orizm.config.ts").option("--dry-run", "display change-events without applying schema.", false).option("-y, --yes", "apply schema without confirmation.", false).action(
|
|
1715
|
-
async (options) => {
|
|
1716
|
-
try {
|
|
1717
|
-
spinner5.start("Loading environment variables...");
|
|
1718
|
-
const env = await loadEnv(options.env);
|
|
1719
|
-
spinner5.succeed("Loaded environment variables.");
|
|
1720
|
-
spinner5.start("Loading project config...");
|
|
1721
|
-
const projectDef = await loadConfig(options.config);
|
|
1722
|
-
spinner5.succeed("Loaded project config.");
|
|
1723
|
-
spinner5.start("Fetch schema change events...");
|
|
1724
|
-
const changeEvents = await getChangeEvents(env, projectDef);
|
|
1725
|
-
spinner5.succeed("Fetch schema change events.");
|
|
1726
|
-
await displayChangeEvents(changeEvents);
|
|
1727
|
-
if (changeEvents.tableChangeEvents.length === 0 && changeEvents.bucketChangeEvents.length === 0 && changeEvents.authorityChangeEvents.length === 0) {
|
|
1728
|
-
return;
|
|
1729
|
-
}
|
|
1730
|
-
if (options.dryRun) {
|
|
1731
|
-
return;
|
|
1732
|
-
}
|
|
1733
|
-
if (!options.yes) {
|
|
1734
|
-
const confirm = await input("Do you want to apply schema? (y/N): ");
|
|
1735
|
-
if (confirm !== "y") {
|
|
1736
|
-
console.log(chalk6.red("Canceled."));
|
|
1737
|
-
return;
|
|
1738
|
-
}
|
|
1739
|
-
}
|
|
1740
|
-
spinner5.start("Applying schema...");
|
|
1741
|
-
await applyDefinition(env, projectDef);
|
|
1742
|
-
spinner5.succeed("Schema applied.");
|
|
1743
|
-
} catch (error2) {
|
|
1744
|
-
handleError(error2);
|
|
1745
|
-
}
|
|
1746
|
-
}
|
|
1747
|
-
);
|
|
1748
|
-
|
|
1749
|
-
// src/config/validate/command.ts
|
|
1750
|
-
import { Command as Command6 } from "commander";
|
|
1751
|
-
import chalk7 from "chalk";
|
|
1752
|
-
import * as v5 from "valibot";
|
|
1753
|
-
|
|
1754
|
-
// src/config/validate/watcher.ts
|
|
1755
|
-
import chokidar from "chokidar";
|
|
1756
|
-
function watchConfigFile(configPath, onFileChange) {
|
|
1757
|
-
const watcher = chokidar.watch(configPath, {
|
|
1758
|
-
persistent: true,
|
|
1759
|
-
ignoreInitial: true
|
|
1760
|
-
});
|
|
1761
|
-
let isProcessing = false;
|
|
1762
|
-
let timeoutId = null;
|
|
1763
|
-
const debouncedOnChange = () => {
|
|
1764
|
-
if (isProcessing) return;
|
|
1765
|
-
if (timeoutId) {
|
|
1766
|
-
clearTimeout(timeoutId);
|
|
1767
|
-
}
|
|
1768
|
-
timeoutId = setTimeout(async () => {
|
|
1769
|
-
isProcessing = true;
|
|
1770
|
-
try {
|
|
1771
|
-
await onFileChange();
|
|
1772
|
-
} catch (error2) {
|
|
1773
|
-
handleError(error2);
|
|
1774
|
-
} finally {
|
|
1775
|
-
isProcessing = false;
|
|
1776
|
-
}
|
|
1777
|
-
}, 300);
|
|
1778
|
-
};
|
|
1779
|
-
watcher.on("change", debouncedOnChange);
|
|
1780
|
-
watcher.on("add", debouncedOnChange);
|
|
1781
|
-
watcher.on("unlink", debouncedOnChange);
|
|
1782
|
-
const terminate = () => {
|
|
1783
|
-
watcher.close();
|
|
1784
|
-
process.exit(0);
|
|
1785
|
-
};
|
|
1786
|
-
process.on("SIGINT", terminate);
|
|
1787
|
-
process.on("SIGTERM", terminate);
|
|
1788
|
-
watcher.on("error", (error2) => {
|
|
1789
|
-
handleError(error2);
|
|
1790
|
-
});
|
|
1791
|
-
return watcher;
|
|
1792
|
-
}
|
|
1793
|
-
|
|
1794
|
-
// src/config/validate/command.ts
|
|
1795
|
-
var validateConfigCommand = new Command6("validate").description("validate orizm.config.ts for validation errors").option("-c, --config <path>", "Path to config file", "./orizm.config.ts").option("-w, --watch", "Watch for file changes and re-validate").action(async (options) => {
|
|
1796
|
-
try {
|
|
1797
|
-
const validateConfig = async () => {
|
|
1798
|
-
try {
|
|
1799
|
-
if (options.watch) {
|
|
1800
|
-
console.clear();
|
|
1801
|
-
console.log(
|
|
1802
|
-
`\u{1F440} Watching ${options.config} for changes... (Press Ctrl+C to stop)`
|
|
1803
|
-
);
|
|
1804
|
-
console.log();
|
|
1805
|
-
}
|
|
1806
|
-
await loadConfig(options.config);
|
|
1807
|
-
console.log(chalk7.green("\u2705 Config is valid."));
|
|
1808
|
-
} catch (error2) {
|
|
1809
|
-
if (v5.isValiError(error2)) {
|
|
1810
|
-
console.error(chalk7.red("\u274C Config validation failed:"));
|
|
1811
|
-
displayValibotError(error2);
|
|
1812
|
-
return;
|
|
1813
|
-
}
|
|
1814
|
-
throw error2;
|
|
1815
|
-
}
|
|
1816
|
-
};
|
|
1817
|
-
await validateConfig();
|
|
1818
|
-
if (options.watch) {
|
|
1819
|
-
watchConfigFile(options.config, validateConfig);
|
|
1820
|
-
}
|
|
1821
|
-
} catch (error2) {
|
|
1822
|
-
handleError(error2);
|
|
1823
|
-
}
|
|
1824
|
-
});
|
|
1825
|
-
|
|
1826
|
-
// src/config/generate-erd/command.ts
|
|
1827
|
-
import { Command as Command7 } from "commander";
|
|
1828
|
-
|
|
1829
|
-
// src/config/generate-erd/generate.ts
|
|
1830
|
-
function generate3(input2) {
|
|
1831
|
-
const tables = input2.tables.map((table) => {
|
|
1832
|
-
const columns = [
|
|
1833
|
-
" id string PK",
|
|
1834
|
-
...table.columns.map(
|
|
1835
|
-
(col) => ` ${col.name} ${col.type}${col.isForeignKey ? " FK" : ""}`
|
|
1836
|
-
)
|
|
1837
|
-
].join("\n");
|
|
1838
|
-
return ` ${table.name} {
|
|
1839
|
-
${columns}
|
|
1840
|
-
}`;
|
|
1841
|
-
}).join("\n");
|
|
1842
|
-
const relations = input2.relations.map((rel) => ` ${rel.from} ${rel.type} ${rel.to} : ${rel.comment}`).join("\n");
|
|
1843
|
-
return `generated by @orizm/cli
|
|
1844
|
-
|
|
1845
|
-
\`\`\`mermaid
|
|
1846
|
-
erDiagram
|
|
1847
|
-
${tables}
|
|
1848
|
-
|
|
1849
|
-
${relations}
|
|
1850
|
-
\`\`\``;
|
|
1851
|
-
}
|
|
1852
|
-
|
|
1853
|
-
// src/config/generate-erd/convert-to-input.ts
|
|
1854
|
-
function convertToInput(config) {
|
|
1855
|
-
const tables = [];
|
|
1856
|
-
const relations = [];
|
|
1857
|
-
for (const table of config.tables) {
|
|
1858
|
-
const modules = [];
|
|
1859
|
-
const erdTable = {
|
|
1860
|
-
name: table.name,
|
|
1861
|
-
columns: []
|
|
1862
|
-
};
|
|
1863
|
-
for (const column of table.columns) {
|
|
1864
|
-
erdTable.columns.push({
|
|
1865
|
-
name: column.name,
|
|
1866
|
-
type: column.type,
|
|
1867
|
-
isForeignKey: column.type === "reference"
|
|
1868
|
-
});
|
|
1869
|
-
if (column.type === "reference") {
|
|
1870
|
-
relations.push({
|
|
1871
|
-
from: column.tableName,
|
|
1872
|
-
to: table.name,
|
|
1873
|
-
type: RELATION.ONE_TO_MANY,
|
|
1874
|
-
comment: "reference"
|
|
1875
|
-
});
|
|
1876
|
-
}
|
|
1877
|
-
if (column.type === "module" || column.type === "module-array") {
|
|
1878
|
-
const module = config.tableModules?.find(
|
|
1879
|
-
(m) => m.name === column.moduleName
|
|
1880
|
-
);
|
|
1881
|
-
if (!module) {
|
|
1882
|
-
continue;
|
|
1883
|
-
}
|
|
1884
|
-
const moduleTableName = `${table.name}_${column.name}_${column.moduleName}`;
|
|
1885
|
-
modules.push({
|
|
1886
|
-
name: moduleTableName,
|
|
1887
|
-
columns: module.columns.map((c) => ({
|
|
1888
|
-
name: c.name,
|
|
1889
|
-
type: c.type,
|
|
1890
|
-
isForeignKey: c.type === "reference"
|
|
1891
|
-
}))
|
|
1892
|
-
});
|
|
1893
|
-
relations.push({
|
|
1894
|
-
from: table.name,
|
|
1895
|
-
to: moduleTableName,
|
|
1896
|
-
type: column.type === "module" ? RELATION.ONE_TO_ONE : RELATION.ONE_TO_MANY,
|
|
1897
|
-
comment: column.type === "module" ? "module" : "module-array"
|
|
1898
|
-
});
|
|
1899
|
-
for (const moduleColumn of module.columns) {
|
|
1900
|
-
if (moduleColumn.type === "reference" && moduleColumn.tableName) {
|
|
1901
|
-
relations.push({
|
|
1902
|
-
from: moduleTableName,
|
|
1903
|
-
to: moduleColumn.tableName,
|
|
1904
|
-
type: RELATION.ONE_TO_MANY,
|
|
1905
|
-
comment: "reference"
|
|
1906
|
-
});
|
|
1907
|
-
}
|
|
1908
|
-
}
|
|
1909
|
-
}
|
|
1910
|
-
}
|
|
1911
|
-
tables.push(erdTable);
|
|
1912
|
-
tables.push(...modules);
|
|
1913
|
-
}
|
|
1914
|
-
return {
|
|
1915
|
-
tables,
|
|
1916
|
-
relations
|
|
1917
|
-
};
|
|
1918
|
-
}
|
|
1919
|
-
var RELATION = {
|
|
1920
|
-
ONE_TO_MANY: "||--o{",
|
|
1921
|
-
ONE_TO_ONE: "||--||"
|
|
1922
|
-
};
|
|
1923
|
-
|
|
1924
|
-
// src/config/generate-erd/command.ts
|
|
1925
|
-
var generateErdCommand = new Command7("generate-erd").description("generate er diagram in mermaid format from orizm.config.ts").option("-c, --config <path>", "orizm config file path.", "orizm.config.ts").action(async (options) => {
|
|
1926
|
-
try {
|
|
1927
|
-
const config = await loadConfig(options.config);
|
|
1928
|
-
const input2 = convertToInput(config);
|
|
1929
|
-
const mermaidText = generate3(input2);
|
|
1930
|
-
console.log(mermaidText);
|
|
1931
|
-
} catch (error2) {
|
|
1932
|
-
handleError(error2);
|
|
1933
|
-
}
|
|
1934
|
-
});
|
|
1935
|
-
|
|
1936
|
-
// src/cli.ts
|
|
1937
|
-
program.name("orizm CLI");
|
|
1938
|
-
program.addCommand(pushCommand);
|
|
1939
|
-
var cmsCommands = new Command8("cms").description("cms commands.");
|
|
1940
|
-
cmsCommands.addCommand(cmsGenerateCommand);
|
|
1941
|
-
cmsCommands.addCommand(cmsPullCommand);
|
|
1942
|
-
program.addCommand(cmsCommands);
|
|
1943
|
-
var consumerCommands = new Command8("consumer").description(
|
|
1944
|
-
"consumer commands."
|
|
1945
|
-
);
|
|
1946
|
-
consumerCommands.addCommand(consumerGenerateCommand);
|
|
1947
|
-
consumerCommands.addCommand(consumerPullCommand);
|
|
1948
|
-
program.addCommand(consumerCommands);
|
|
1949
|
-
var configCommands = new Command8("config").description("config commands.");
|
|
1950
|
-
configCommands.addCommand(validateConfigCommand);
|
|
1951
|
-
configCommands.addCommand(generateErdCommand);
|
|
1952
|
-
program.addCommand(configCommands);
|
|
1953
|
-
program.parse();
|
|
1954
|
-
//# sourceMappingURL=cli.js.map
|