@scalar/cli 2.0.1 → 2.1.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 +40 -0
- package/chunks/action-45OGQB2M.js +138 -0
- package/chunks/action-5R5FDF6S.js +2097 -0
- package/chunks/action-ANU5HGC4.js +34 -0
- package/chunks/action-BMFXENMX.js +176 -0
- package/chunks/action-BNEGJBUH.js +38 -0
- package/chunks/action-BYZUBXVB.js +82 -0
- package/chunks/action-C5VB4ITT.js +132 -0
- package/chunks/action-CCW66QJN.js +72 -0
- package/chunks/action-CLSD7O2R.js +60 -0
- package/chunks/action-CQ56FVES.js +65 -0
- package/chunks/action-CYP4VDK3.js +148 -0
- package/chunks/action-DFKHSDFV.js +36 -0
- package/chunks/action-F4Y6Q2VB.js +92 -0
- package/chunks/action-GB6DM53B.js +70 -0
- package/chunks/action-GEBRPNRT.js +87 -0
- package/chunks/action-H5OHT2GV.js +56 -0
- package/chunks/action-HD2T6BFJ.js +54 -0
- package/chunks/action-HNKM3Q65.js +65 -0
- package/chunks/action-JOSVV6YA.js +71 -0
- package/chunks/action-MENXFJH3.js +204 -0
- package/chunks/action-P7LN6FGY.js +13 -0
- package/chunks/action-PVDDRIM6.js +130 -0
- package/chunks/action-Q5UJ32D6.js +46 -0
- package/chunks/action-R6ZZO26F.js +299 -0
- package/chunks/action-STIEAXOE.js +53 -0
- package/chunks/action-TPBKPHNS.js +110 -0
- package/chunks/action-TWFJNQ2R.js +95 -0
- package/chunks/action-TZ5KGAQT.js +64 -0
- package/chunks/action-UDZUUJSI.js +49 -0
- package/chunks/action-W5BATF4Q.js +197 -0
- package/chunks/agent-XGLOHXNA.js +112 -0
- package/chunks/build.action-LKOILPA6.js +108 -0
- package/chunks/chunk-23I5PKZZ.js +78 -0
- package/chunks/chunk-2BSG2QHO.js +455 -0
- package/chunks/chunk-3MZYUBJ6.js +49 -0
- package/chunks/chunk-47Y4L5IT.js +63361 -0
- package/chunks/chunk-4DGQIAJX.js +359 -0
- package/chunks/chunk-4QS7SJTG.js +138 -0
- package/chunks/chunk-5BISXQX4.js +447 -0
- package/chunks/chunk-5BPPGTUU.js +463 -0
- package/chunks/chunk-AEFPCC4U.js +16 -0
- package/chunks/chunk-AHWWJ3MD.js +32 -0
- package/chunks/chunk-ASMHW5AY.js +19 -0
- package/chunks/chunk-B6QZJWCQ.js +92 -0
- package/chunks/chunk-DOVIWNKQ.js +108 -0
- package/chunks/chunk-H2WRMLYY.js +13780 -0
- package/chunks/chunk-HQKBZOYU.js +34 -0
- package/chunks/chunk-ISGLWBXZ.js +4265 -0
- package/chunks/chunk-IX7LJ3AD.js +17 -0
- package/chunks/chunk-JFIXNSPP.js +26 -0
- package/chunks/chunk-K74E42RV.js +7311 -0
- package/chunks/chunk-KHDYYVYF.js +16 -0
- package/chunks/chunk-KWOL7A6J.js +23 -0
- package/chunks/chunk-NUXPNUSS.js +38 -0
- package/chunks/chunk-OAXFCOJV.js +25 -0
- package/chunks/chunk-P2VH7DOC.js +107 -0
- package/chunks/chunk-P646T2WH.js +1608 -0
- package/chunks/chunk-SHSHFGA7.js +297 -0
- package/chunks/chunk-SXYALPYK.js +2709 -0
- package/chunks/chunk-T7B6WNZC.js +18 -0
- package/chunks/chunk-T7MDADON.js +17 -0
- package/chunks/chunk-TLFMATXR.js +344 -0
- package/chunks/chunk-TQ5XC2E3.js +284 -0
- package/chunks/chunk-UPUTMFD4.js +465 -0
- package/chunks/chunk-VTYTPSXO.js +161 -0
- package/chunks/chunk-X4QLDBB5.js +221 -0
- package/chunks/chunk-ZTVWAKNJ.js +21 -0
- package/chunks/create.action-FFQLBSJH.js +108 -0
- package/chunks/delete.action-QNN3LC2F.js +96 -0
- package/chunks/delete.action-STHQHP4F.js +88 -0
- package/chunks/get.action-OTKYOP3Z.js +87 -0
- package/chunks/list.action-6I5EZAVB.js +95 -0
- package/chunks/list.action-KDM5RHEH.js +116 -0
- package/chunks/publish.action-PODTVRXS.js +182 -0
- package/chunks/update.action-4F6STTEQ.js +101 -0
- package/chunks/update.action-KMD4ZM75.js +95 -0
- package/docs.html +310 -209
- package/index.js +645 -99061
- package/package.json +13 -11
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
apiService
|
|
4
|
+
} from "./chunk-SXYALPYK.js";
|
|
5
|
+
import {
|
|
6
|
+
BaseCollections
|
|
7
|
+
} from "./chunk-2BSG2QHO.js";
|
|
8
|
+
import {
|
|
9
|
+
getDatabaseClient
|
|
10
|
+
} from "./chunk-SHSHFGA7.js";
|
|
11
|
+
import "./chunk-UPUTMFD4.js";
|
|
12
|
+
import "./chunk-B6QZJWCQ.js";
|
|
13
|
+
import {
|
|
14
|
+
sdkSchema
|
|
15
|
+
} from "./chunk-5BPPGTUU.js";
|
|
16
|
+
import "./chunk-P646T2WH.js";
|
|
17
|
+
import "./chunk-4QS7SJTG.js";
|
|
18
|
+
import "./chunk-VTYTPSXO.js";
|
|
19
|
+
import {
|
|
20
|
+
getAuthData
|
|
21
|
+
} from "./chunk-5BISXQX4.js";
|
|
22
|
+
import "./chunk-OAXFCOJV.js";
|
|
23
|
+
import "./chunk-TLFMATXR.js";
|
|
24
|
+
import {
|
|
25
|
+
teamSchema
|
|
26
|
+
} from "./chunk-4DGQIAJX.js";
|
|
27
|
+
import {
|
|
28
|
+
docVersionSchema,
|
|
29
|
+
namespaceSchema,
|
|
30
|
+
slugSchema
|
|
31
|
+
} from "./chunk-ISGLWBXZ.js";
|
|
32
|
+
import {
|
|
33
|
+
external_exports
|
|
34
|
+
} from "./chunk-H2WRMLYY.js";
|
|
35
|
+
import "./chunk-K74E42RV.js";
|
|
36
|
+
import "./chunk-IX7LJ3AD.js";
|
|
37
|
+
import {
|
|
38
|
+
output
|
|
39
|
+
} from "./chunk-X4QLDBB5.js";
|
|
40
|
+
import "./chunk-3MZYUBJ6.js";
|
|
41
|
+
|
|
42
|
+
// src/domains/sdk/build.action.ts
|
|
43
|
+
import { select } from "@clack/prompts";
|
|
44
|
+
async function buildAction(opts) {
|
|
45
|
+
const { error, data } = external_exports.object({
|
|
46
|
+
slug: slugSchema.optional(),
|
|
47
|
+
namespace: namespaceSchema.optional(),
|
|
48
|
+
version: docVersionSchema.optional()
|
|
49
|
+
}).safeParse(opts);
|
|
50
|
+
if (error)
|
|
51
|
+
return output.error().title("Invalid input").message(error.issues[0].message).exit("error");
|
|
52
|
+
const auth = await getAuthData();
|
|
53
|
+
auth.addEventListener((state) => Object.assign(auth, state));
|
|
54
|
+
const db = await getDatabaseClient();
|
|
55
|
+
const client = await apiService();
|
|
56
|
+
const team = await db.getOne({
|
|
57
|
+
collectionPath: BaseCollections.Teams,
|
|
58
|
+
query: {
|
|
59
|
+
uid: auth.teamUid
|
|
60
|
+
},
|
|
61
|
+
schema: teamSchema
|
|
62
|
+
});
|
|
63
|
+
if (team.error)
|
|
64
|
+
return output.error().title("An error occurred when fetching your team.").message(team.message).exit("error");
|
|
65
|
+
const namespace = data.namespace || team.data.namespaces.at(0);
|
|
66
|
+
if (!namespace) {
|
|
67
|
+
return output.error().title("Missing namespace").message(
|
|
68
|
+
"Could not find a valid namespace for your SDK. Please specify a namespace or contact support."
|
|
69
|
+
).exit("error");
|
|
70
|
+
}
|
|
71
|
+
const sdks = await db.getMany({
|
|
72
|
+
collectionPath: BaseCollections.Sdks(team.data.uid),
|
|
73
|
+
query: {
|
|
74
|
+
namespace
|
|
75
|
+
},
|
|
76
|
+
schema: sdkSchema.array()
|
|
77
|
+
});
|
|
78
|
+
if (sdks.error) return output.error().title(sdks.message).exit("error");
|
|
79
|
+
const sdkUid = sdks.data.find((sdk) => sdk.slug === data.slug)?.uid || await select({
|
|
80
|
+
message: "Please select an SDK to update",
|
|
81
|
+
options: sdks.data.map((sdk) => ({
|
|
82
|
+
value: sdk.uid,
|
|
83
|
+
label: sdk.slug
|
|
84
|
+
}))
|
|
85
|
+
});
|
|
86
|
+
const matchingSdk = sdks.data.find((sdk) => sdk.uid === sdkUid);
|
|
87
|
+
if (!matchingSdk) {
|
|
88
|
+
return output.error().title("No SDK found").message("Please provide a valid SDK slug").exit("error");
|
|
89
|
+
}
|
|
90
|
+
const version = matchingSdk.versions.find((v) => v.version === data.version)?.version || await select({
|
|
91
|
+
message: "Please select an SDK version to build",
|
|
92
|
+
options: matchingSdk.versions.map((version2) => ({
|
|
93
|
+
value: version2.version,
|
|
94
|
+
label: `v${version2.version}`
|
|
95
|
+
}))
|
|
96
|
+
});
|
|
97
|
+
const logger = output.info().loader("Creating SDK Build");
|
|
98
|
+
const response = await client.sdks.build(sdkUid, version);
|
|
99
|
+
if (response.error) {
|
|
100
|
+
return output.error().title("Something went wrong").message(response.message).exit("error");
|
|
101
|
+
}
|
|
102
|
+
logger.update("loader", 0, {
|
|
103
|
+
content: `SDK build kicked off for version v${version}`
|
|
104
|
+
}).exit("success");
|
|
105
|
+
}
|
|
106
|
+
export {
|
|
107
|
+
buildAction
|
|
108
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
isUrl
|
|
4
|
+
} from "./chunk-IX7LJ3AD.js";
|
|
5
|
+
import {
|
|
6
|
+
output
|
|
7
|
+
} from "./chunk-X4QLDBB5.js";
|
|
8
|
+
|
|
9
|
+
// src/domains/document/helpers/banner.ts
|
|
10
|
+
import as from "ansis";
|
|
11
|
+
var printSpecificationBanner = (result) => {
|
|
12
|
+
const { version, schema } = result;
|
|
13
|
+
if (!schema?.info?.title || !version) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const pathsCount = Object.keys(schema.paths ?? {}).length;
|
|
17
|
+
const operationsCount = Object.values(schema.paths ?? {}).reduce(
|
|
18
|
+
(acc, path) => acc + Object.keys(path).length,
|
|
19
|
+
0
|
|
20
|
+
);
|
|
21
|
+
output.info().title(
|
|
22
|
+
`${as.white.bold(schema?.info?.title)} ${as.grey(`(OpenAPI v${version})`)}`
|
|
23
|
+
).title(as.grey(`${pathsCount} paths, ${operationsCount} operations`)).print();
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// src/domains/document/helpers/imports.ts
|
|
27
|
+
import fs from "node:fs";
|
|
28
|
+
import as2 from "ansis";
|
|
29
|
+
import { load, validate } from "@scalar/openapi-parser";
|
|
30
|
+
var getFileOrUrl = async (input) => {
|
|
31
|
+
if (isUrl(input)) {
|
|
32
|
+
const response = await fetch(input);
|
|
33
|
+
if (!response.ok) {
|
|
34
|
+
return output.error().title("Failed to fetch from URL.").exit("error");
|
|
35
|
+
}
|
|
36
|
+
return await response.text();
|
|
37
|
+
}
|
|
38
|
+
if (!fs.existsSync(input)) {
|
|
39
|
+
return output.error().title("Could not read file.").exit("error");
|
|
40
|
+
}
|
|
41
|
+
return fs.readFileSync(input, "utf-8");
|
|
42
|
+
};
|
|
43
|
+
var loadOpenApiFile = async (input) => {
|
|
44
|
+
const specification = await getFileOrUrl(input);
|
|
45
|
+
try {
|
|
46
|
+
const { filesystem } = await load(specification);
|
|
47
|
+
const result = await validate(filesystem);
|
|
48
|
+
if (!result.valid) {
|
|
49
|
+
output.warn().title("File does not match the OpenAPI specification.").print();
|
|
50
|
+
result.errors?.forEach((error) => {
|
|
51
|
+
output.warn().title(`${error.error} (${error.path})`).print();
|
|
52
|
+
});
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
return result;
|
|
56
|
+
} catch (error) {
|
|
57
|
+
output.error().title(error ? as2.red(error.toString()) : "Unknown error.").print();
|
|
58
|
+
const message = typeof error === "object" && error !== null && "message" in error ? String(error.message) : "Unknown error";
|
|
59
|
+
return {
|
|
60
|
+
valid: false,
|
|
61
|
+
version: void 0,
|
|
62
|
+
specification: void 0,
|
|
63
|
+
schema: void 0,
|
|
64
|
+
errors: [
|
|
65
|
+
{
|
|
66
|
+
message,
|
|
67
|
+
path: []
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export {
|
|
75
|
+
printSpecificationBanner,
|
|
76
|
+
getFileOrUrl,
|
|
77
|
+
loadOpenApiFile
|
|
78
|
+
};
|
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
accessGroupSchema,
|
|
4
|
+
identityProviderRecordSchema,
|
|
5
|
+
loginPortalSchema,
|
|
6
|
+
managedSchema,
|
|
7
|
+
workspaceSchema
|
|
8
|
+
} from "./chunk-UPUTMFD4.js";
|
|
9
|
+
import {
|
|
10
|
+
userSchema
|
|
11
|
+
} from "./chunk-B6QZJWCQ.js";
|
|
12
|
+
import {
|
|
13
|
+
sdkSchema
|
|
14
|
+
} from "./chunk-5BPPGTUU.js";
|
|
15
|
+
import {
|
|
16
|
+
managedDocSchema,
|
|
17
|
+
ruleSchema
|
|
18
|
+
} from "./chunk-4QS7SJTG.js";
|
|
19
|
+
import {
|
|
20
|
+
teamSchema
|
|
21
|
+
} from "./chunk-4DGQIAJX.js";
|
|
22
|
+
import {
|
|
23
|
+
activeDeploymentSchema,
|
|
24
|
+
emailSchema,
|
|
25
|
+
entitySchema,
|
|
26
|
+
nanoidSchema,
|
|
27
|
+
publishRecordSchema,
|
|
28
|
+
themeSchema
|
|
29
|
+
} from "./chunk-ISGLWBXZ.js";
|
|
30
|
+
import {
|
|
31
|
+
external_exports,
|
|
32
|
+
zod_default
|
|
33
|
+
} from "./chunk-H2WRMLYY.js";
|
|
34
|
+
|
|
35
|
+
// ../../packages/entities/dist/admins/index.js
|
|
36
|
+
var scalarAdminSchema = entitySchema.extend({
|
|
37
|
+
email: zod_default.string().email(),
|
|
38
|
+
name: zod_default.string().min(2).max(100),
|
|
39
|
+
role: zod_default.enum(["admin", "super-admin"])
|
|
40
|
+
}).meta({ id: "scalar-admin" });
|
|
41
|
+
|
|
42
|
+
// ../../packages/entities/dist/publish/publish.js
|
|
43
|
+
var headingRecordSchema = external_exports.object({
|
|
44
|
+
slug: external_exports.string(),
|
|
45
|
+
name: external_exports.string(),
|
|
46
|
+
level: external_exports.coerce.number().int(),
|
|
47
|
+
uid: nanoidSchema,
|
|
48
|
+
parent: external_exports.string().optional(),
|
|
49
|
+
isPageTitle: external_exports.boolean().optional()
|
|
50
|
+
}).meta({ id: "heading-record" });
|
|
51
|
+
var publishAssetSchema = external_exports.object({
|
|
52
|
+
path: external_exports.string(),
|
|
53
|
+
data: external_exports.string()
|
|
54
|
+
}).meta({ id: "publish-asset" });
|
|
55
|
+
var typesenseConfigSchema = external_exports.object({
|
|
56
|
+
keyId: external_exports.number(),
|
|
57
|
+
keyValue: external_exports.string(),
|
|
58
|
+
collectionName: external_exports.string()
|
|
59
|
+
}).meta({ id: "typesense-config" });
|
|
60
|
+
|
|
61
|
+
// ../../packages/entities/dist/deploys/deploy.js
|
|
62
|
+
var subpathSchema = external_exports.object({
|
|
63
|
+
subpath: external_exports.string(),
|
|
64
|
+
projectUid: external_exports.string(),
|
|
65
|
+
/**
|
|
66
|
+
* Present only for sites still served by Typesense. Builds on the jsonl
|
|
67
|
+
* search backend omit it; federated search fetches `${subpath}/search-entries.jsonl`.
|
|
68
|
+
*/
|
|
69
|
+
typesenseConfig: typesenseConfigSchema.optional().nullable()
|
|
70
|
+
}).meta({ id: "subpath" });
|
|
71
|
+
var siteDeploySchema = entitySchema.extend({
|
|
72
|
+
domain: external_exports.string(),
|
|
73
|
+
teamUid: nanoidSchema,
|
|
74
|
+
projectUid: nanoidSchema,
|
|
75
|
+
subpaths: subpathSchema.array().default([])
|
|
76
|
+
}).meta({ id: "site-deploy" });
|
|
77
|
+
var searchConfigResponseSchema = external_exports.object({
|
|
78
|
+
subpaths: subpathSchema.array()
|
|
79
|
+
}).meta({ id: "search-config-response" });
|
|
80
|
+
|
|
81
|
+
// ../../packages/entities/dist/user/ban.js
|
|
82
|
+
var bannedUserSchema = entitySchema.extend({
|
|
83
|
+
email: emailSchema,
|
|
84
|
+
reason: zod_default.string(),
|
|
85
|
+
bannedBy: emailSchema
|
|
86
|
+
}).meta({ id: "banned-user" });
|
|
87
|
+
|
|
88
|
+
// ../../packages/entities/dist/database/collections.js
|
|
89
|
+
var BaseCollections = {
|
|
90
|
+
Users: "users",
|
|
91
|
+
ScalarAdmins: "admin-users",
|
|
92
|
+
SignupMeta: "signup-meta",
|
|
93
|
+
ExchangeTokens: "exchange-tokens",
|
|
94
|
+
HostingExchange: "hosting-exchange",
|
|
95
|
+
HostingLoginTokens: "hosting-login-tokens",
|
|
96
|
+
HostingOauthStates: "hosting-oauth-states",
|
|
97
|
+
Passwords: "passwords",
|
|
98
|
+
SignupOtp: "signup-otp",
|
|
99
|
+
GithubUsers: "github-users",
|
|
100
|
+
BitbucketUsers: "bitbucket-users",
|
|
101
|
+
RefreshTokens: "refresh-tokens",
|
|
102
|
+
LoginAttempts: "login-attempts",
|
|
103
|
+
Teams: "team",
|
|
104
|
+
Deploys: "deploys",
|
|
105
|
+
SamlStates: "saml-states",
|
|
106
|
+
SignupData: "signup-data",
|
|
107
|
+
Projects: (teamUid) => `team/${teamUid}/projects`,
|
|
108
|
+
GithubProjects: (teamUid) => `team/${teamUid}/projects-github`,
|
|
109
|
+
DocsProjects: (teamUid) => `team/${teamUid}/docs`,
|
|
110
|
+
Themes: (teamUid) => `team/${teamUid}/themes`,
|
|
111
|
+
PublishRecords: (teamUid) => `team/${teamUid}/publish`,
|
|
112
|
+
ManagedDocs: (teamUid) => `team/${teamUid}/managed-docs`,
|
|
113
|
+
ManagedSchemas: (teamUid) => `team/${teamUid}/managed-schemas`,
|
|
114
|
+
Rules: (teamUid) => `team/${teamUid}/rules`,
|
|
115
|
+
RegistryPublishes: (teamUid) => `team/${teamUid}/registry-publishes`,
|
|
116
|
+
RegistryGitMigrations: "registry-git-migrations",
|
|
117
|
+
AccessGroups: (teamUid) => `team/${teamUid}/access-groups`,
|
|
118
|
+
LoginPortals: (teamUid) => `team/${teamUid}/login-portals`,
|
|
119
|
+
Sdks: (teamUid) => `team/${teamUid}/sdks`,
|
|
120
|
+
SdkBuilds: (teamUid) => `team/${teamUid}/sdk-builds`,
|
|
121
|
+
SdkBuildLogs: (teamUid) => `team/${teamUid}/sdk-build-logs`,
|
|
122
|
+
PersonalTokens: (userUid) => `user/${userUid}/personal-tokens`,
|
|
123
|
+
IdentityProviders: (teamUid) => `team/${teamUid}/identity-providers`,
|
|
124
|
+
Workspaces: (teamUid) => `team/${teamUid}/workspaces`,
|
|
125
|
+
OauthStates: "oauth-states",
|
|
126
|
+
Waitlist: "waitlist",
|
|
127
|
+
BannedUsers: "banned-users"
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
// ../../packages/entities/dist/database/edge-cache.js
|
|
131
|
+
var requiredUid = { uid: nanoidSchema };
|
|
132
|
+
var entityExtension = {
|
|
133
|
+
...requiredUid,
|
|
134
|
+
_path: external_exports.string(),
|
|
135
|
+
_registryPath: external_exports.string().default("")
|
|
136
|
+
};
|
|
137
|
+
var registryRequiredFields = {
|
|
138
|
+
uid: true,
|
|
139
|
+
title: true,
|
|
140
|
+
slug: true,
|
|
141
|
+
namespace: true,
|
|
142
|
+
loginPortalUid: true,
|
|
143
|
+
isPrivate: true,
|
|
144
|
+
accessGroups: true
|
|
145
|
+
};
|
|
146
|
+
function generateRegistryPath(entity) {
|
|
147
|
+
entity._registryPath = `${entity.namespace}/${entity.slug}`;
|
|
148
|
+
return entity;
|
|
149
|
+
}
|
|
150
|
+
function teamUidFromPath(path) {
|
|
151
|
+
return path.split("/").at(1) ?? "";
|
|
152
|
+
}
|
|
153
|
+
var edgeCacheDeploySchema = siteDeploySchema.extend(requiredUid);
|
|
154
|
+
var edgeCacheProjectSchema = external_exports.object({
|
|
155
|
+
...requiredUid,
|
|
156
|
+
loginPortalUid: external_exports.string().default(""),
|
|
157
|
+
accessGroups: external_exports.array(external_exports.string()).default([]),
|
|
158
|
+
identityProviders: external_exports.string().array().default([]),
|
|
159
|
+
isPrivate: external_exports.boolean().default(false),
|
|
160
|
+
/**
|
|
161
|
+
* The customer's docs-analytics opt-out. It defaults to true, so a cache
|
|
162
|
+
* that omits the field silently opts an opted-out customer back in — the
|
|
163
|
+
* hosting proxy projects it on every project collection for this reason.
|
|
164
|
+
*/
|
|
165
|
+
analyticsEnabled: external_exports.boolean().default(true),
|
|
166
|
+
activeDeployment: activeDeploymentSchema.nullable().optional(),
|
|
167
|
+
_path: external_exports.string()
|
|
168
|
+
});
|
|
169
|
+
var edgeCacheGithubProjectSchema = edgeCacheProjectSchema;
|
|
170
|
+
var edgeCacheDocsProjectSchema = edgeCacheProjectSchema;
|
|
171
|
+
var PROJECT_TABLE = "project";
|
|
172
|
+
var edgeCachePublishRecordSchema = publishRecordSchema.pick({ uid: true, projectUid: true, agentToken: true }).extend(requiredUid).transform(({ uid, projectUid, agentToken }) => ({
|
|
173
|
+
uid,
|
|
174
|
+
projectUid,
|
|
175
|
+
agentToken,
|
|
176
|
+
_publishPath: `${uid.toLowerCase()}/${projectUid}`
|
|
177
|
+
}));
|
|
178
|
+
var edgeCacheApiSchema = managedDocSchema.pick({
|
|
179
|
+
...registryRequiredFields,
|
|
180
|
+
theme: true,
|
|
181
|
+
version: true,
|
|
182
|
+
versions: true,
|
|
183
|
+
agentEnabled: true
|
|
184
|
+
}).extend(entityExtension).transform(generateRegistryPath);
|
|
185
|
+
var edgeCacheSchemaSchema = managedSchema.pick({ ...registryRequiredFields, version: true, versions: true }).extend(entityExtension).transform(generateRegistryPath);
|
|
186
|
+
var edgeCacheRuleSchema = ruleSchema.pick(registryRequiredFields).extend(entityExtension).transform(generateRegistryPath);
|
|
187
|
+
var edgeCacheSdkSchema = sdkSchema.pick({ ...registryRequiredFields, versions: true, targets: true }).extend(entityExtension).transform(generateRegistryPath);
|
|
188
|
+
var edgeCacheWorkspaceSchema = workspaceSchema.pick({ ...registryRequiredFields, version: true, versions: true }).extend(entityExtension).transform(generateRegistryPath);
|
|
189
|
+
var edgeCacheTeamSchema = teamSchema.pick({
|
|
190
|
+
uid: true,
|
|
191
|
+
users: true,
|
|
192
|
+
externalAccess: true
|
|
193
|
+
}).extend(requiredUid);
|
|
194
|
+
var edgeCacheUserSchema = userSchema.pick({
|
|
195
|
+
uid: true,
|
|
196
|
+
email: true
|
|
197
|
+
}).extend(requiredUid);
|
|
198
|
+
var edgeCacheLoginPortalSchema = loginPortalSchema.extend(requiredUid);
|
|
199
|
+
var edgeCacheAccessGroupSchema = accessGroupSchema.extend(requiredUid);
|
|
200
|
+
var edgeCacheThemeSchema = themeSchema.pick({ uid: true, theme: true, slug: true }).extend({ ...requiredUid, _path: external_exports.string() });
|
|
201
|
+
var edgeCacheIdentityProviderSchema = identityProviderRecordSchema.extend({ _path: external_exports.string() }).pick({
|
|
202
|
+
uid: true,
|
|
203
|
+
name: true,
|
|
204
|
+
provider: true,
|
|
205
|
+
consumerOnly: true,
|
|
206
|
+
_path: true
|
|
207
|
+
}).extend(requiredUid).transform(({ uid, name, provider, consumerOnly, _path }) => ({
|
|
208
|
+
uid,
|
|
209
|
+
name,
|
|
210
|
+
provider,
|
|
211
|
+
consumerOnly,
|
|
212
|
+
teamUid: teamUidFromPath(_path),
|
|
213
|
+
_path
|
|
214
|
+
}));
|
|
215
|
+
var SAFE_SQL_IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
216
|
+
function assertSafeIdentifier(value, context) {
|
|
217
|
+
if (!SAFE_SQL_IDENTIFIER.test(value)) {
|
|
218
|
+
throw new Error(`Unsafe SQL identifier for edge-cache ${context}: ${JSON.stringify(value)}`);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
function defineCollection(config) {
|
|
222
|
+
assertSafeIdentifier(config.tableName, `tableName "${config.tableName}"`);
|
|
223
|
+
for (const field of config.indexFields) {
|
|
224
|
+
assertSafeIdentifier(field, `indexField "${field}" on "${config.tableName}"`);
|
|
225
|
+
}
|
|
226
|
+
if (config.source !== void 0) {
|
|
227
|
+
assertSafeIdentifier(config.source, `source "${config.source}" on "${config.tableName}"`);
|
|
228
|
+
}
|
|
229
|
+
return config;
|
|
230
|
+
}
|
|
231
|
+
var edgeCacheCollections = {
|
|
232
|
+
deploy: defineCollection({
|
|
233
|
+
schema: edgeCacheDeploySchema,
|
|
234
|
+
indexFields: ["domain"],
|
|
235
|
+
tableName: "deploy",
|
|
236
|
+
mongoCollection: BaseCollections.Deploys
|
|
237
|
+
}),
|
|
238
|
+
project: defineCollection({
|
|
239
|
+
schema: edgeCacheProjectSchema,
|
|
240
|
+
indexFields: [],
|
|
241
|
+
tableName: PROJECT_TABLE,
|
|
242
|
+
mongoCollection: BaseCollections.Projects,
|
|
243
|
+
source: "project",
|
|
244
|
+
projection: {
|
|
245
|
+
uid: 1,
|
|
246
|
+
loginPortalUid: 1,
|
|
247
|
+
accessGroups: 1,
|
|
248
|
+
identityProviders: 1,
|
|
249
|
+
isPrivate: 1,
|
|
250
|
+
analyticsEnabled: 1,
|
|
251
|
+
activeDeployment: 1,
|
|
252
|
+
_path: 1
|
|
253
|
+
}
|
|
254
|
+
}),
|
|
255
|
+
githubProject: defineCollection({
|
|
256
|
+
schema: edgeCacheGithubProjectSchema,
|
|
257
|
+
indexFields: [],
|
|
258
|
+
tableName: PROJECT_TABLE,
|
|
259
|
+
mongoCollection: BaseCollections.GithubProjects,
|
|
260
|
+
source: "github",
|
|
261
|
+
projection: {
|
|
262
|
+
uid: 1,
|
|
263
|
+
loginPortalUid: 1,
|
|
264
|
+
accessGroups: 1,
|
|
265
|
+
identityProviders: 1,
|
|
266
|
+
isPrivate: 1,
|
|
267
|
+
analyticsEnabled: 1,
|
|
268
|
+
activeDeployment: 1,
|
|
269
|
+
_path: 1
|
|
270
|
+
}
|
|
271
|
+
}),
|
|
272
|
+
docsProject: defineCollection({
|
|
273
|
+
schema: edgeCacheDocsProjectSchema,
|
|
274
|
+
indexFields: [],
|
|
275
|
+
tableName: PROJECT_TABLE,
|
|
276
|
+
mongoCollection: BaseCollections.DocsProjects,
|
|
277
|
+
source: "docs",
|
|
278
|
+
projection: {
|
|
279
|
+
uid: 1,
|
|
280
|
+
loginPortalUid: 1,
|
|
281
|
+
accessGroups: 1,
|
|
282
|
+
identityProviders: 1,
|
|
283
|
+
isPrivate: 1,
|
|
284
|
+
analyticsEnabled: 1,
|
|
285
|
+
activeDeployment: 1,
|
|
286
|
+
_path: 1
|
|
287
|
+
}
|
|
288
|
+
}),
|
|
289
|
+
publishRecord: defineCollection({
|
|
290
|
+
schema: edgeCachePublishRecordSchema,
|
|
291
|
+
indexFields: ["_publishPath"],
|
|
292
|
+
tableName: "publishRecord",
|
|
293
|
+
mongoCollection: BaseCollections.PublishRecords,
|
|
294
|
+
projection: { uid: 1, projectUid: 1, agentToken: 1 }
|
|
295
|
+
}),
|
|
296
|
+
api: defineCollection({
|
|
297
|
+
schema: edgeCacheApiSchema,
|
|
298
|
+
indexFields: ["_registryPath"],
|
|
299
|
+
tableName: "api",
|
|
300
|
+
mongoCollection: BaseCollections.ManagedDocs,
|
|
301
|
+
projection: {
|
|
302
|
+
uid: 1,
|
|
303
|
+
title: 1,
|
|
304
|
+
slug: 1,
|
|
305
|
+
namespace: 1,
|
|
306
|
+
loginPortalUid: 1,
|
|
307
|
+
isPrivate: 1,
|
|
308
|
+
accessGroups: 1,
|
|
309
|
+
theme: 1,
|
|
310
|
+
_path: 1,
|
|
311
|
+
_registryPath: 1,
|
|
312
|
+
version: 1,
|
|
313
|
+
versions: 1,
|
|
314
|
+
agentEnabled: 1
|
|
315
|
+
}
|
|
316
|
+
}),
|
|
317
|
+
schema: defineCollection({
|
|
318
|
+
schema: edgeCacheSchemaSchema,
|
|
319
|
+
indexFields: ["_registryPath"],
|
|
320
|
+
tableName: "schema",
|
|
321
|
+
mongoCollection: BaseCollections.ManagedSchemas,
|
|
322
|
+
projection: {
|
|
323
|
+
uid: 1,
|
|
324
|
+
title: 1,
|
|
325
|
+
slug: 1,
|
|
326
|
+
namespace: 1,
|
|
327
|
+
loginPortalUid: 1,
|
|
328
|
+
isPrivate: 1,
|
|
329
|
+
accessGroups: 1,
|
|
330
|
+
version: 1,
|
|
331
|
+
versions: 1,
|
|
332
|
+
_path: 1,
|
|
333
|
+
_registryPath: 1
|
|
334
|
+
}
|
|
335
|
+
}),
|
|
336
|
+
rule: defineCollection({
|
|
337
|
+
schema: edgeCacheRuleSchema,
|
|
338
|
+
indexFields: ["_registryPath"],
|
|
339
|
+
tableName: "rule",
|
|
340
|
+
mongoCollection: BaseCollections.Rules,
|
|
341
|
+
projection: {
|
|
342
|
+
uid: 1,
|
|
343
|
+
title: 1,
|
|
344
|
+
slug: 1,
|
|
345
|
+
namespace: 1,
|
|
346
|
+
loginPortalUid: 1,
|
|
347
|
+
isPrivate: 1,
|
|
348
|
+
accessGroups: 1,
|
|
349
|
+
_path: 1,
|
|
350
|
+
_registryPath: 1
|
|
351
|
+
}
|
|
352
|
+
}),
|
|
353
|
+
sdk: defineCollection({
|
|
354
|
+
schema: edgeCacheSdkSchema,
|
|
355
|
+
indexFields: ["_registryPath"],
|
|
356
|
+
tableName: "sdk",
|
|
357
|
+
mongoCollection: BaseCollections.Sdks,
|
|
358
|
+
projection: {
|
|
359
|
+
uid: 1,
|
|
360
|
+
title: 1,
|
|
361
|
+
slug: 1,
|
|
362
|
+
namespace: 1,
|
|
363
|
+
loginPortalUid: 1,
|
|
364
|
+
isPrivate: 1,
|
|
365
|
+
accessGroups: 1,
|
|
366
|
+
versions: 1,
|
|
367
|
+
targets: 1,
|
|
368
|
+
_path: 1,
|
|
369
|
+
_registryPath: 1
|
|
370
|
+
}
|
|
371
|
+
}),
|
|
372
|
+
workspace: defineCollection({
|
|
373
|
+
schema: edgeCacheWorkspaceSchema,
|
|
374
|
+
indexFields: ["_registryPath"],
|
|
375
|
+
tableName: "workspace",
|
|
376
|
+
mongoCollection: BaseCollections.Workspaces,
|
|
377
|
+
projection: {
|
|
378
|
+
uid: 1,
|
|
379
|
+
title: 1,
|
|
380
|
+
slug: 1,
|
|
381
|
+
namespace: 1,
|
|
382
|
+
loginPortalUid: 1,
|
|
383
|
+
isPrivate: 1,
|
|
384
|
+
accessGroups: 1,
|
|
385
|
+
version: 1,
|
|
386
|
+
versions: 1,
|
|
387
|
+
_registryPath: 1,
|
|
388
|
+
_path: 1
|
|
389
|
+
}
|
|
390
|
+
}),
|
|
391
|
+
team: defineCollection({
|
|
392
|
+
schema: edgeCacheTeamSchema,
|
|
393
|
+
indexFields: [],
|
|
394
|
+
tableName: "team",
|
|
395
|
+
mongoCollection: BaseCollections.Teams,
|
|
396
|
+
projection: { uid: 1, users: 1, externalAccess: 1 }
|
|
397
|
+
}),
|
|
398
|
+
user: defineCollection({
|
|
399
|
+
schema: edgeCacheUserSchema,
|
|
400
|
+
indexFields: ["email"],
|
|
401
|
+
tableName: "user",
|
|
402
|
+
mongoCollection: BaseCollections.Users,
|
|
403
|
+
projection: { uid: 1, email: 1 }
|
|
404
|
+
}),
|
|
405
|
+
loginPortal: defineCollection({
|
|
406
|
+
schema: edgeCacheLoginPortalSchema,
|
|
407
|
+
indexFields: [],
|
|
408
|
+
tableName: "loginPortal",
|
|
409
|
+
mongoCollection: BaseCollections.LoginPortals
|
|
410
|
+
}),
|
|
411
|
+
accessGroup: defineCollection({
|
|
412
|
+
schema: edgeCacheAccessGroupSchema,
|
|
413
|
+
indexFields: [],
|
|
414
|
+
tableName: "accessGroup",
|
|
415
|
+
mongoCollection: BaseCollections.AccessGroups
|
|
416
|
+
}),
|
|
417
|
+
theme: defineCollection({
|
|
418
|
+
schema: edgeCacheThemeSchema,
|
|
419
|
+
indexFields: [],
|
|
420
|
+
tableName: "theme",
|
|
421
|
+
mongoCollection: BaseCollections.Themes,
|
|
422
|
+
projection: { uid: 1, theme: 1, slug: 1, _path: 1 }
|
|
423
|
+
}),
|
|
424
|
+
identityProvider: defineCollection({
|
|
425
|
+
schema: edgeCacheIdentityProviderSchema,
|
|
426
|
+
indexFields: ["teamUid"],
|
|
427
|
+
tableName: "identityProvider",
|
|
428
|
+
mongoCollection: BaseCollections.IdentityProviders,
|
|
429
|
+
projection: { uid: 1, name: 1, provider: 1, consumerOnly: 1, _path: 1 }
|
|
430
|
+
})
|
|
431
|
+
};
|
|
432
|
+
var sharedTables = new Set(Object.values(edgeCacheCollections).map((config) => config.tableName).filter((table, index, all) => all.indexOf(table) !== index));
|
|
433
|
+
for (const [key, config] of Object.entries(edgeCacheCollections)) {
|
|
434
|
+
const shared = sharedTables.has(config.tableName);
|
|
435
|
+
if (shared && !config.source) {
|
|
436
|
+
throw new Error(`Edge-cache collection "${key}" shares table "${config.tableName}" but declares no source.`);
|
|
437
|
+
}
|
|
438
|
+
if (!shared && config.source) {
|
|
439
|
+
throw new Error(`Edge-cache collection "${key}" declares source "${config.source}" but no other collection uses table "${config.tableName}".`);
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
var sourcesByTable = /* @__PURE__ */ new Map();
|
|
443
|
+
for (const [key, config] of Object.entries(edgeCacheCollections)) {
|
|
444
|
+
if (!config.source)
|
|
445
|
+
continue;
|
|
446
|
+
const seen = sourcesByTable.get(`${config.tableName}:${config.source}`);
|
|
447
|
+
if (seen) {
|
|
448
|
+
throw new Error(`Edge-cache collections "${seen}" and "${key}" both use source "${config.source}" on table "${config.tableName}".`);
|
|
449
|
+
}
|
|
450
|
+
sourcesByTable.set(`${config.tableName}:${config.source}`, key);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
export {
|
|
454
|
+
BaseCollections
|
|
455
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
9
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
10
|
+
}) : x)(function(x) {
|
|
11
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
12
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
13
|
+
});
|
|
14
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
15
|
+
try {
|
|
16
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
17
|
+
} catch (e) {
|
|
18
|
+
throw mod = 0, e;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
var __export = (target, all) => {
|
|
22
|
+
for (var name in all)
|
|
23
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
24
|
+
};
|
|
25
|
+
var __copyProps = (to, from, except, desc) => {
|
|
26
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
27
|
+
for (let key of __getOwnPropNames(from))
|
|
28
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
29
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
30
|
+
}
|
|
31
|
+
return to;
|
|
32
|
+
};
|
|
33
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
34
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
35
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
36
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
37
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
38
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
39
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
40
|
+
mod
|
|
41
|
+
));
|
|
42
|
+
|
|
43
|
+
export {
|
|
44
|
+
__require,
|
|
45
|
+
__commonJS,
|
|
46
|
+
__export,
|
|
47
|
+
__reExport,
|
|
48
|
+
__toESM
|
|
49
|
+
};
|