storybooker 0.19.3 → 0.22.0-canary.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 -18
- package/dist/adapters/_internal/queue.d.mts +127 -0
- package/dist/aws-dynamodb.d.mts +22 -0
- package/dist/aws-dynamodb.mjs +118 -0
- package/dist/aws-dynamodb.mjs.map +1 -0
- package/dist/aws-s3.d.mts +20 -0
- package/dist/aws-s3.mjs +96 -0
- package/dist/aws-s3.mjs.map +1 -0
- package/dist/azure-blob-storage.d.mts +20 -0
- package/dist/azure-blob-storage.mjs +126 -0
- package/dist/azure-blob-storage.mjs.map +1 -0
- package/dist/azure-cosmos-db.d.mts +23 -0
- package/dist/azure-cosmos-db.mjs +87 -0
- package/dist/azure-cosmos-db.mjs.map +1 -0
- package/dist/azure-data-tables.d.mts +23 -0
- package/dist/azure-data-tables.mjs +127 -0
- package/dist/azure-data-tables.mjs.map +1 -0
- package/dist/azure-easy-auth.d.mts +50 -0
- package/dist/azure-easy-auth.mjs +88 -0
- package/dist/azure-easy-auth.mjs.map +1 -0
- package/dist/azure-functions.d.mts +62 -0
- package/dist/azure-functions.mjs +147 -0
- package/dist/azure-functions.mjs.map +1 -0
- package/dist/fs.d.mts +37 -0
- package/dist/fs.mjs +240 -0
- package/dist/fs.mjs.map +1 -0
- package/dist/gcp-big-table.d.mts +23 -0
- package/dist/gcp-big-table.mjs +92 -0
- package/dist/gcp-big-table.mjs.map +1 -0
- package/dist/gcp-firestore.d.mts +22 -0
- package/dist/gcp-firestore.mjs +87 -0
- package/dist/gcp-firestore.mjs.map +1 -0
- package/dist/gcp-storage.d.mts +20 -0
- package/dist/gcp-storage.mjs +96 -0
- package/dist/gcp-storage.mjs.map +1 -0
- package/dist/handlers/handle-process-zip.mjs +90 -0
- package/dist/handlers/handle-process-zip.mjs.map +1 -0
- package/dist/handlers/handle-purge.d.mts +12 -0
- package/dist/handlers/handle-purge.mjs +36 -0
- package/dist/handlers/handle-purge.mjs.map +1 -0
- package/dist/handlers/handle-serve-storybook.mjs +94 -0
- package/dist/handlers/handle-serve-storybook.mjs.map +1 -0
- package/dist/index.d.mts +28 -0
- package/dist/index.mjs +62 -0
- package/dist/index.mjs.map +1 -0
- package/dist/models/builds-model.mjs +248 -0
- package/dist/models/builds-model.mjs.map +1 -0
- package/dist/models/builds-schema.d.mts +171 -0
- package/dist/models/builds-schema.mjs +67 -0
- package/dist/models/builds-schema.mjs.map +1 -0
- package/dist/models/projects-model.mjs +122 -0
- package/dist/models/projects-model.mjs.map +1 -0
- package/dist/models/projects-schema.d.mts +70 -0
- package/dist/models/projects-schema.mjs +37 -0
- package/dist/models/projects-schema.mjs.map +1 -0
- package/dist/models/tags-model.mjs +110 -0
- package/dist/models/tags-model.mjs.map +1 -0
- package/dist/models/tags-schema.d.mts +76 -0
- package/dist/models/tags-schema.mjs +34 -0
- package/dist/models/tags-schema.mjs.map +1 -0
- package/dist/models/~model.mjs +43 -0
- package/dist/models/~model.mjs.map +1 -0
- package/dist/models/~shared-schema.d.mts +1 -0
- package/dist/models/~shared-schema.mjs +20 -0
- package/dist/models/~shared-schema.mjs.map +1 -0
- package/dist/mysql.d.mts +39 -0
- package/dist/mysql.mjs +151 -0
- package/dist/mysql.mjs.map +1 -0
- package/dist/redis.d.mts +33 -0
- package/dist/redis.mjs +118 -0
- package/dist/redis.mjs.map +1 -0
- package/dist/routers/account-router.mjs +91 -0
- package/dist/routers/account-router.mjs.map +1 -0
- package/dist/routers/builds-router.mjs +347 -0
- package/dist/routers/builds-router.mjs.map +1 -0
- package/dist/routers/projects-router.mjs +236 -0
- package/dist/routers/projects-router.mjs.map +1 -0
- package/dist/routers/root-router.mjs +108 -0
- package/dist/routers/root-router.mjs.map +1 -0
- package/dist/routers/tags-router.mjs +269 -0
- package/dist/routers/tags-router.mjs.map +1 -0
- package/dist/routers/tasks-router.mjs +71 -0
- package/dist/routers/tasks-router.mjs.map +1 -0
- package/dist/urls.d.mts +47 -0
- package/dist/urls.mjs +208 -0
- package/dist/urls.mjs.map +1 -0
- package/dist/utils/adapter-utils.d.mts +14 -0
- package/dist/utils/adapter-utils.mjs +14 -0
- package/dist/utils/adapter-utils.mjs.map +1 -0
- package/dist/utils/auth.mjs +25 -0
- package/dist/utils/auth.mjs.map +1 -0
- package/dist/utils/error.d.mts +21 -0
- package/dist/utils/error.mjs +109 -0
- package/dist/utils/error.mjs.map +1 -0
- package/dist/utils/file-utils.mjs +16 -0
- package/dist/utils/file-utils.mjs.map +1 -0
- package/dist/utils/openapi-utils.mjs +45 -0
- package/dist/utils/openapi-utils.mjs.map +1 -0
- package/dist/utils/request.mjs +35 -0
- package/dist/utils/request.mjs.map +1 -0
- package/dist/utils/response.mjs +24 -0
- package/dist/utils/response.mjs.map +1 -0
- package/dist/utils/store.mjs +54 -0
- package/dist/utils/store.mjs.map +1 -0
- package/dist/utils/ui-utils.mjs +38 -0
- package/dist/utils/ui-utils.mjs.map +1 -0
- package/dist/utils/url-utils.d.mts +10 -0
- package/dist/utils/url-utils.mjs +54 -0
- package/dist/utils/url-utils.mjs.map +1 -0
- package/dist/~internal/adapter/auth.d.mts +123 -0
- package/dist/~internal/adapter/auth.mjs +20 -0
- package/dist/~internal/adapter/auth.mjs.map +1 -0
- package/dist/~internal/adapter/database.d.mts +240 -0
- package/dist/~internal/adapter/database.mjs +63 -0
- package/dist/~internal/adapter/database.mjs.map +1 -0
- package/dist/~internal/adapter/logger.d.mts +34 -0
- package/dist/~internal/adapter/logger.mjs +13 -0
- package/dist/~internal/adapter/logger.mjs.map +1 -0
- package/dist/~internal/adapter/storage.d.mts +208 -0
- package/dist/~internal/adapter/storage.mjs +63 -0
- package/dist/~internal/adapter/storage.mjs.map +1 -0
- package/dist/~internal/adapter/ui.d.mts +109 -0
- package/dist/~internal/adapter/ui.mjs +1 -0
- package/dist/~internal/adapter.d.mts +8 -0
- package/dist/~internal/adapter.mjs +6 -0
- package/dist/~internal/constants.d.mts +24 -0
- package/dist/~internal/constants.mjs +32 -0
- package/dist/~internal/constants.mjs.map +1 -0
- package/dist/~internal/mimes.d.mts +449 -0
- package/dist/~internal/mimes.mjs +454 -0
- package/dist/~internal/mimes.mjs.map +1 -0
- package/dist/~internal/router.d.mts +1651 -0
- package/dist/~internal/router.mjs +39 -0
- package/dist/~internal/router.mjs.map +1 -0
- package/dist/~internal/types.d.mts +77 -0
- package/dist/~internal/types.mjs +1 -0
- package/dist/~internal/utils.d.mts +4 -0
- package/dist/~internal/utils.mjs +5 -0
- package/openapi.json +3162 -0
- package/package.json +148 -27
- package/src/adapters/_internal/auth.ts +135 -0
- package/src/adapters/_internal/database.ts +241 -0
- package/src/adapters/_internal/index.ts +8 -0
- package/src/adapters/_internal/logger.ts +41 -0
- package/src/adapters/_internal/queue.ts +151 -0
- package/src/adapters/_internal/storage.ts +197 -0
- package/src/adapters/_internal/ui.ts +103 -0
- package/src/adapters/aws-dynamodb.ts +201 -0
- package/src/adapters/aws-s3.ts +160 -0
- package/src/adapters/azure-blob-storage.ts +223 -0
- package/src/adapters/azure-cosmos-db.ts +158 -0
- package/src/adapters/azure-data-tables.ts +223 -0
- package/src/adapters/azure-easy-auth.ts +174 -0
- package/src/adapters/azure-functions.ts +242 -0
- package/src/adapters/fs.ts +398 -0
- package/src/adapters/gcp-big-table.ts +157 -0
- package/src/adapters/gcp-firestore.ts +146 -0
- package/src/adapters/gcp-storage.ts +141 -0
- package/src/adapters/mysql.ts +296 -0
- package/src/adapters/redis.ts +242 -0
- package/src/handlers/handle-process-zip.ts +117 -0
- package/src/handlers/handle-purge.ts +65 -0
- package/src/handlers/handle-serve-storybook.ts +101 -0
- package/src/index.ts +81 -16
- package/src/mocks/mock-auth-service.ts +51 -0
- package/src/mocks/mock-store.ts +26 -0
- package/src/models/builds-model.ts +373 -0
- package/src/models/builds-schema.ts +84 -0
- package/src/models/projects-model.ts +177 -0
- package/src/models/projects-schema.ts +69 -0
- package/src/models/tags-model.ts +138 -0
- package/src/models/tags-schema.ts +45 -0
- package/src/models/~model.ts +79 -0
- package/src/models/~shared-schema.ts +14 -0
- package/src/routers/_app-router.ts +57 -0
- package/src/routers/account-router.ts +136 -0
- package/src/routers/builds-router.ts +464 -0
- package/src/routers/projects-router.ts +309 -0
- package/src/routers/root-router.ts +127 -0
- package/src/routers/tags-router.ts +339 -0
- package/src/routers/tasks-router.ts +75 -0
- package/src/types.ts +107 -0
- package/src/urls.ts +327 -0
- package/src/utils/adapter-utils.ts +26 -0
- package/src/utils/auth.test.ts +71 -0
- package/src/utils/auth.ts +39 -0
- package/src/utils/constants.ts +31 -0
- package/src/utils/date-utils.ts +10 -0
- package/src/utils/error.test.ts +86 -0
- package/src/utils/error.ts +140 -0
- package/src/utils/file-utils.test.ts +65 -0
- package/src/utils/file-utils.ts +43 -0
- package/src/utils/index.ts +3 -0
- package/src/utils/mime-utils.ts +457 -0
- package/src/utils/openapi-utils.ts +49 -0
- package/src/utils/request.ts +97 -0
- package/src/utils/response.ts +20 -0
- package/src/utils/store.ts +85 -0
- package/src/utils/story-utils.ts +42 -0
- package/src/utils/text-utils.ts +10 -0
- package/src/utils/ui-utils.ts +57 -0
- package/src/utils/url-utils.ts +113 -0
- package/dist/index.js +0 -554
- package/src/commands/create.ts +0 -263
- package/src/commands/purge.ts +0 -70
- package/src/commands/test.ts +0 -42
- package/src/service-schema.d.ts +0 -2023
- package/src/utils/auth-utils.ts +0 -31
- package/src/utils/pkg-utils.ts +0 -37
- package/src/utils/sb-build.ts +0 -55
- package/src/utils/sb-test.ts +0 -115
- package/src/utils/schema-utils.ts +0 -123
- package/src/utils/stream-utils.ts +0 -72
- package/src/utils/types.ts +0 -4
- package/src/utils/zip.ts +0 -77
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projects-model.mjs","names":["project: ProjectType"],"sources":["../../src/models/projects-model.ts"],"sourcesContent":["import { HTTPException } from \"hono/http-exception\";\nimport type { StoryBookerPermissionAction } from \"../adapters/_internal/auth.ts\";\nimport {\n generateDatabaseCollectionId,\n generateStorageContainerId,\n} from \"../utils/adapter-utils.ts\";\nimport { checkAuthorisation } from \"../utils/auth.ts\";\nimport {\n ProjectSchema,\n type ProjectCreateType,\n type ProjectType,\n type ProjectUpdateType,\n} from \"./projects-schema.ts\";\nimport { TagsModel } from \"./tags-model.ts\";\nimport { Model, type BaseModel, type ListOptions } from \"./~model.ts\";\n\nexport class ProjectsModel extends Model<ProjectType> {\n constructor() {\n super(null, generateDatabaseCollectionId(\"Projects\", \"\"));\n }\n\n async list(options: ListOptions<ProjectType> = {}): Promise<ProjectType[]> {\n this.log(\"List projects...\");\n\n try {\n const items = await this.database.listDocuments(this.collectionId, options, this.dbOptions);\n\n return items;\n } catch (error) {\n this.error(\"Error listing projects:\", error);\n return [];\n }\n }\n\n async create(data: ProjectCreateType): Promise<ProjectType> {\n this.log(\"Creating project...\");\n\n const projectId = data.id;\n\n try {\n if (await this.has(projectId)) {\n throw new HTTPException(409, {\n message: `Project '${projectId}' already exists.`,\n });\n }\n\n await this.storage.createContainer(\n generateStorageContainerId(projectId),\n this.storageOptions,\n );\n\n this.debug(\"Creating project collection\");\n await this.database\n .createCollection(this.collectionId, this.dbOptions)\n .catch((error: unknown) => {\n // ignore error if collection already exists since there can only be one projects collection\n this.error(\"Error creating projects collection:\", error);\n });\n\n await this.database.createCollection(\n generateDatabaseCollectionId(projectId, \"Builds\"),\n this.dbOptions,\n );\n\n await this.database.createCollection(\n generateDatabaseCollectionId(projectId, \"Tags\"),\n this.dbOptions,\n );\n\n this.debug(\"Creating default branch (%s) tag\", data.gitHubDefaultBranch);\n await new TagsModel(projectId)\n .create({\n type: \"branch\",\n value: data.gitHubDefaultBranch,\n })\n .catch((error: unknown) => {\n // log error but continue since project creation should not fail because of tag creation\n this.error(\"Error creating default branch tag:\", error);\n });\n\n this.debug(\"Creating project entry '%s' in collection\", projectId);\n const now = new Date().toISOString();\n const project: ProjectType = {\n ...data,\n createdAt: now,\n updatedAt: now,\n };\n await this.database.createDocument(this.collectionId, project, this.dbOptions);\n\n return project;\n } catch (error) {\n throw new HTTPException(500, {\n cause: error,\n message: `Failed to create project '${projectId}'.`,\n });\n }\n }\n\n async get(id: string): Promise<ProjectType> {\n this.log(\"Get project '%s'...\", id);\n\n const item = await this.database.getDocument(this.collectionId, id, this.dbOptions);\n\n return ProjectSchema.parse(item);\n }\n\n async has(id: string): Promise<boolean> {\n this.log(\"Check project '%s'...\", id);\n\n try {\n return await this.database.hasDocument(this.collectionId, id, this.dbOptions);\n } catch {\n return false;\n }\n }\n\n async update(id: string, data: ProjectUpdateType): Promise<void> {\n this.log(\"Update project '%s'...\", id);\n\n await this.database.updateDocument(\n this.collectionId,\n id,\n { ...data, updatedAt: new Date().toISOString() },\n this.dbOptions,\n );\n\n if (data.gitHubDefaultBranch) {\n try {\n this.debug(\"Create default-branch tag '%s'...\", data.gitHubDefaultBranch);\n await new TagsModel(id).create({\n type: \"branch\",\n value: data.gitHubDefaultBranch,\n });\n } catch (error) {\n this.error(\"Error creating default branch tag:\", error);\n }\n }\n }\n\n async delete(id: string): Promise<void> {\n this.log(\"Delete project '%s'...\", id);\n\n this.debug(\"Delete project entry '%s' in collection\", id);\n await this.database.deleteDocument(this.collectionId, id, this.dbOptions);\n\n this.debug(\"Delete project-builds collection\");\n await this.database.deleteCollection(\n generateDatabaseCollectionId(id, \"Builds\"),\n this.dbOptions,\n );\n\n this.debug(\"Delete project-tags collection\");\n await this.database.deleteCollection(generateDatabaseCollectionId(id, \"Tags\"), this.dbOptions);\n\n this.debug(\"Delete project container\");\n await this.storage.deleteContainer(generateStorageContainerId(id), this.storageOptions);\n }\n\n checkAuth(action: StoryBookerPermissionAction, id?: string): boolean {\n return checkAuthorisation({\n action,\n projectId: id ?? (this.projectId || undefined),\n resource: \"project\",\n });\n }\n\n id: BaseModel<ProjectType>[\"id\"] = (id: string) => {\n return {\n checkAuth: (action) => checkAuthorisation({ action, projectId: id, resource: \"project\" }),\n delete: this.delete.bind(this, id),\n get: this.get.bind(this, id),\n has: this.has.bind(this, id),\n id,\n update: this.update.bind(this, id),\n };\n };\n}\n"],"mappings":";;;;;;;;AAgBA,IAAa,gBAAb,cAAmC,MAAmB;CACpD,cAAc;AACZ,QAAM,MAAM,6BAA6B,YAAY,GAAG,CAAC;;CAG3D,MAAM,KAAK,UAAoC,EAAE,EAA0B;AACzE,OAAK,IAAI,mBAAmB;AAE5B,MAAI;AAGF,UAFc,MAAM,KAAK,SAAS,cAAc,KAAK,cAAc,SAAS,KAAK,UAAU;WAGpF,OAAO;AACd,QAAK,MAAM,2BAA2B,MAAM;AAC5C,UAAO,EAAE;;;CAIb,MAAM,OAAO,MAA+C;AAC1D,OAAK,IAAI,sBAAsB;EAE/B,MAAM,YAAY,KAAK;AAEvB,MAAI;AACF,OAAI,MAAM,KAAK,IAAI,UAAU,CAC3B,OAAM,IAAI,cAAc,KAAK,EAC3B,SAAS,YAAY,UAAU,oBAChC,CAAC;AAGJ,SAAM,KAAK,QAAQ,gBACjB,2BAA2B,UAAU,EACrC,KAAK,eACN;AAED,QAAK,MAAM,8BAA8B;AACzC,SAAM,KAAK,SACR,iBAAiB,KAAK,cAAc,KAAK,UAAU,CACnD,OAAO,UAAmB;AAEzB,SAAK,MAAM,uCAAuC,MAAM;KACxD;AAEJ,SAAM,KAAK,SAAS,iBAClB,6BAA6B,WAAW,SAAS,EACjD,KAAK,UACN;AAED,SAAM,KAAK,SAAS,iBAClB,6BAA6B,WAAW,OAAO,EAC/C,KAAK,UACN;AAED,QAAK,MAAM,oCAAoC,KAAK,oBAAoB;AACxE,SAAM,IAAI,UAAU,UAAU,CAC3B,OAAO;IACN,MAAM;IACN,OAAO,KAAK;IACb,CAAC,CACD,OAAO,UAAmB;AAEzB,SAAK,MAAM,sCAAsC,MAAM;KACvD;AAEJ,QAAK,MAAM,6CAA6C,UAAU;GAClE,MAAM,uBAAM,IAAI,MAAM,EAAC,aAAa;GACpC,MAAMA,UAAuB;IAC3B,GAAG;IACH,WAAW;IACX,WAAW;IACZ;AACD,SAAM,KAAK,SAAS,eAAe,KAAK,cAAc,SAAS,KAAK,UAAU;AAE9E,UAAO;WACA,OAAO;AACd,SAAM,IAAI,cAAc,KAAK;IAC3B,OAAO;IACP,SAAS,6BAA6B,UAAU;IACjD,CAAC;;;CAIN,MAAM,IAAI,IAAkC;AAC1C,OAAK,IAAI,uBAAuB,GAAG;EAEnC,MAAM,OAAO,MAAM,KAAK,SAAS,YAAY,KAAK,cAAc,IAAI,KAAK,UAAU;AAEnF,SAAO,cAAc,MAAM,KAAK;;CAGlC,MAAM,IAAI,IAA8B;AACtC,OAAK,IAAI,yBAAyB,GAAG;AAErC,MAAI;AACF,UAAO,MAAM,KAAK,SAAS,YAAY,KAAK,cAAc,IAAI,KAAK,UAAU;UACvE;AACN,UAAO;;;CAIX,MAAM,OAAO,IAAY,MAAwC;AAC/D,OAAK,IAAI,0BAA0B,GAAG;AAEtC,QAAM,KAAK,SAAS,eAClB,KAAK,cACL,IACA;GAAE,GAAG;GAAM,4BAAW,IAAI,MAAM,EAAC,aAAa;GAAE,EAChD,KAAK,UACN;AAED,MAAI,KAAK,oBACP,KAAI;AACF,QAAK,MAAM,qCAAqC,KAAK,oBAAoB;AACzE,SAAM,IAAI,UAAU,GAAG,CAAC,OAAO;IAC7B,MAAM;IACN,OAAO,KAAK;IACb,CAAC;WACK,OAAO;AACd,QAAK,MAAM,sCAAsC,MAAM;;;CAK7D,MAAM,OAAO,IAA2B;AACtC,OAAK,IAAI,0BAA0B,GAAG;AAEtC,OAAK,MAAM,2CAA2C,GAAG;AACzD,QAAM,KAAK,SAAS,eAAe,KAAK,cAAc,IAAI,KAAK,UAAU;AAEzE,OAAK,MAAM,mCAAmC;AAC9C,QAAM,KAAK,SAAS,iBAClB,6BAA6B,IAAI,SAAS,EAC1C,KAAK,UACN;AAED,OAAK,MAAM,iCAAiC;AAC5C,QAAM,KAAK,SAAS,iBAAiB,6BAA6B,IAAI,OAAO,EAAE,KAAK,UAAU;AAE9F,OAAK,MAAM,2BAA2B;AACtC,QAAM,KAAK,QAAQ,gBAAgB,2BAA2B,GAAG,EAAE,KAAK,eAAe;;CAGzF,UAAU,QAAqC,IAAsB;AACnE,SAAO,mBAAmB;GACxB;GACA,WAAW,OAAO,KAAK,aAAa;GACpC,UAAU;GACX,CAAC;;CAGJ,MAAoC,OAAe;AACjD,SAAO;GACL,YAAY,WAAW,mBAAmB;IAAE;IAAQ,WAAW;IAAI,UAAU;IAAW,CAAC;GACzF,QAAQ,KAAK,OAAO,KAAK,MAAM,GAAG;GAClC,KAAK,KAAK,IAAI,KAAK,MAAM,GAAG;GAC5B,KAAK,KAAK,IAAI,KAAK,MAAM,GAAG;GAC5B;GACA,QAAQ,KAAK,OAAO,KAAK,MAAM,GAAG;GACnC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import "./~shared-schema.mjs";
|
|
2
|
+
import { z } from "@hono/zod-openapi";
|
|
3
|
+
|
|
4
|
+
//#region src/models/projects-schema.d.ts
|
|
5
|
+
type ProjectType = z.infer<typeof ProjectSchema>;
|
|
6
|
+
declare const ProjectSchema: z.ZodObject<{
|
|
7
|
+
createdAt: z.ZodDefault<z.ZodISODateTime>;
|
|
8
|
+
gitHubDefaultBranch: z.ZodDefault<z.ZodString>;
|
|
9
|
+
gitHubPath: z.ZodOptional<z.ZodString>;
|
|
10
|
+
gitHubRepository: z.ZodString;
|
|
11
|
+
id: z.ZodString;
|
|
12
|
+
jiraDomain: z.ZodUnion<readonly [z.ZodOptional<z.ZodURL>, z.ZodLiteral<"">]>;
|
|
13
|
+
latestBuildId: z.ZodUnion<readonly [z.ZodOptional<z.ZodString>, z.ZodLiteral<"">]>;
|
|
14
|
+
name: z.ZodString;
|
|
15
|
+
purgeBuildsAfterDays: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
16
|
+
updatedAt: z.ZodDefault<z.ZodISODateTime>;
|
|
17
|
+
}, z.core.$strip>;
|
|
18
|
+
type ProjectCreateType = z.infer<typeof ProjectCreateSchema>;
|
|
19
|
+
declare const ProjectCreateSchema: z.ZodObject<{
|
|
20
|
+
gitHubDefaultBranch: z.ZodDefault<z.ZodString>;
|
|
21
|
+
gitHubPath: z.ZodOptional<z.ZodString>;
|
|
22
|
+
gitHubRepository: z.ZodString;
|
|
23
|
+
id: z.ZodString;
|
|
24
|
+
jiraDomain: z.ZodUnion<readonly [z.ZodOptional<z.ZodURL>, z.ZodLiteral<"">]>;
|
|
25
|
+
name: z.ZodString;
|
|
26
|
+
purgeBuildsAfterDays: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
27
|
+
}, z.core.$strip>;
|
|
28
|
+
type ProjectUpdateType = z.infer<typeof ProjectUpdateSchema>;
|
|
29
|
+
declare const ProjectUpdateSchema: z.ZodObject<{
|
|
30
|
+
gitHubPath: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
31
|
+
gitHubRepository: z.ZodOptional<z.ZodString>;
|
|
32
|
+
jiraDomain: z.ZodOptional<z.ZodUnion<readonly [z.ZodOptional<z.ZodURL>, z.ZodLiteral<"">]>>;
|
|
33
|
+
latestBuildId: z.ZodOptional<z.ZodUnion<readonly [z.ZodOptional<z.ZodString>, z.ZodLiteral<"">]>>;
|
|
34
|
+
name: z.ZodOptional<z.ZodString>;
|
|
35
|
+
purgeBuildsAfterDays: z.ZodOptional<z.ZodDefault<z.ZodCoercedNumber<unknown>>>;
|
|
36
|
+
gitHubDefaultBranch: z.ZodOptional<z.ZodString>;
|
|
37
|
+
}, z.core.$strip>;
|
|
38
|
+
type ProjectsListResultType = z.infer<typeof ProjectsListResultSchema>;
|
|
39
|
+
declare const ProjectsListResultSchema: z.ZodObject<{
|
|
40
|
+
projects: z.ZodArray<z.ZodObject<{
|
|
41
|
+
createdAt: z.ZodDefault<z.ZodISODateTime>;
|
|
42
|
+
gitHubDefaultBranch: z.ZodDefault<z.ZodString>;
|
|
43
|
+
gitHubPath: z.ZodOptional<z.ZodString>;
|
|
44
|
+
gitHubRepository: z.ZodString;
|
|
45
|
+
id: z.ZodString;
|
|
46
|
+
jiraDomain: z.ZodUnion<readonly [z.ZodOptional<z.ZodURL>, z.ZodLiteral<"">]>;
|
|
47
|
+
latestBuildId: z.ZodUnion<readonly [z.ZodOptional<z.ZodString>, z.ZodLiteral<"">]>;
|
|
48
|
+
name: z.ZodString;
|
|
49
|
+
purgeBuildsAfterDays: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
50
|
+
updatedAt: z.ZodDefault<z.ZodISODateTime>;
|
|
51
|
+
}, z.core.$strip>>;
|
|
52
|
+
}, z.core.$strip>;
|
|
53
|
+
type ProjectGetResultType = z.infer<typeof ProjectGetResultSchema>;
|
|
54
|
+
declare const ProjectGetResultSchema: z.ZodObject<{
|
|
55
|
+
project: z.ZodObject<{
|
|
56
|
+
createdAt: z.ZodDefault<z.ZodISODateTime>;
|
|
57
|
+
gitHubDefaultBranch: z.ZodDefault<z.ZodString>;
|
|
58
|
+
gitHubPath: z.ZodOptional<z.ZodString>;
|
|
59
|
+
gitHubRepository: z.ZodString;
|
|
60
|
+
id: z.ZodString;
|
|
61
|
+
jiraDomain: z.ZodUnion<readonly [z.ZodOptional<z.ZodURL>, z.ZodLiteral<"">]>;
|
|
62
|
+
latestBuildId: z.ZodUnion<readonly [z.ZodOptional<z.ZodString>, z.ZodLiteral<"">]>;
|
|
63
|
+
name: z.ZodString;
|
|
64
|
+
purgeBuildsAfterDays: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
65
|
+
updatedAt: z.ZodDefault<z.ZodISODateTime>;
|
|
66
|
+
}, z.core.$strip>;
|
|
67
|
+
}, z.core.$strip>;
|
|
68
|
+
//#endregion
|
|
69
|
+
export { ProjectCreateType, ProjectGetResultType, ProjectType, ProjectUpdateType, ProjectsListResultType };
|
|
70
|
+
//# sourceMappingURL=projects-schema.d.mts.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { DEFAULT_GITHUB_BRANCH, DEFAULT_PURGE_AFTER_DAYS } from "../~internal/constants.mjs";
|
|
2
|
+
import { BuildIdSchema, ProjectIdSchema } from "./~shared-schema.mjs";
|
|
3
|
+
import { z } from "@hono/zod-openapi";
|
|
4
|
+
|
|
5
|
+
//#region src/models/projects-schema.ts
|
|
6
|
+
const ProjectSchema = z.object({
|
|
7
|
+
createdAt: z.iso.datetime().default((/* @__PURE__ */ new Date()).toISOString()),
|
|
8
|
+
gitHubDefaultBranch: z.string().default(DEFAULT_GITHUB_BRANCH).meta({ description: "Default branch to use for GitHub repository" }),
|
|
9
|
+
gitHubPath: z.string().optional().meta({ description: "Path to the storybook project with respect to repository root." }),
|
|
10
|
+
gitHubRepository: z.string().check(z.minLength(1, "Query-param 'gitHubRepo' is required."), z.refine((val) => val.split("/").length === 2, "Query-param 'gitHubRepo' should be in the format 'owner/repo'.")),
|
|
11
|
+
id: ProjectIdSchema,
|
|
12
|
+
jiraDomain: z.union([z.url().optional(), z.literal("")]),
|
|
13
|
+
latestBuildId: z.union([BuildIdSchema.optional(), z.literal("")]),
|
|
14
|
+
name: z.string().meta({ description: "Name of the project." }),
|
|
15
|
+
purgeBuildsAfterDays: z.coerce.number().min(1).default(DEFAULT_PURGE_AFTER_DAYS).meta({ description: "Days after which the builds in the project should be purged." }),
|
|
16
|
+
updatedAt: z.iso.datetime().default((/* @__PURE__ */ new Date()).toISOString())
|
|
17
|
+
}).meta({
|
|
18
|
+
id: "Project",
|
|
19
|
+
title: "StoryBooker project"
|
|
20
|
+
});
|
|
21
|
+
const ProjectCreateSchema = ProjectSchema.omit({
|
|
22
|
+
createdAt: true,
|
|
23
|
+
latestBuildId: true,
|
|
24
|
+
updatedAt: true
|
|
25
|
+
});
|
|
26
|
+
const ProjectUpdateSchema = ProjectSchema.omit({
|
|
27
|
+
createdAt: true,
|
|
28
|
+
gitHubDefaultBranch: true,
|
|
29
|
+
id: true,
|
|
30
|
+
updatedAt: true
|
|
31
|
+
}).extend({ gitHubDefaultBranch: z.string() }).partial();
|
|
32
|
+
const ProjectsListResultSchema = z.object({ projects: ProjectSchema.array() });
|
|
33
|
+
const ProjectGetResultSchema = z.object({ project: ProjectSchema });
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
export { ProjectCreateSchema, ProjectGetResultSchema, ProjectSchema, ProjectUpdateSchema, ProjectsListResultSchema };
|
|
37
|
+
//# sourceMappingURL=projects-schema.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projects-schema.mjs","names":[],"sources":["../../src/models/projects-schema.ts"],"sourcesContent":["import { z } from \"@hono/zod-openapi\";\nimport { DEFAULT_GITHUB_BRANCH, DEFAULT_PURGE_AFTER_DAYS } from \"../utils/constants.ts\";\nimport { BuildIdSchema, ProjectIdSchema } from \"./~shared-schema.ts\";\n\nexport { ProjectIdSchema };\n\nexport type ProjectType = z.infer<typeof ProjectSchema>;\n\nexport const ProjectSchema = z\n .object({\n createdAt: z.iso.datetime().default(new Date().toISOString()),\n\n gitHubDefaultBranch: z\n .string()\n .default(DEFAULT_GITHUB_BRANCH)\n .meta({ description: \"Default branch to use for GitHub repository\" }),\n gitHubPath: z.string().optional().meta({\n description: \"Path to the storybook project with respect to repository root.\",\n }),\n gitHubRepository: z.string().check(\n z.minLength(1, \"Query-param 'gitHubRepo' is required.\"),\n z.refine(\n (val) => val.split(\"/\").length === 2,\n \"Query-param 'gitHubRepo' should be in the format 'owner/repo'.\",\n ),\n ),\n\n id: ProjectIdSchema,\n\n jiraDomain: z.union([z.url().optional(), z.literal(\"\")]),\n\n latestBuildId: z.union([BuildIdSchema.optional(), z.literal(\"\")]),\n\n name: z.string().meta({ description: \"Name of the project.\" }),\n\n purgeBuildsAfterDays: z.coerce.number().min(1).default(DEFAULT_PURGE_AFTER_DAYS).meta({\n description: \"Days after which the builds in the project should be purged.\",\n }),\n\n updatedAt: z.iso.datetime().default(new Date().toISOString()),\n })\n .meta({ id: \"Project\", title: \"StoryBooker project\" });\n\nexport type ProjectCreateType = z.infer<typeof ProjectCreateSchema>;\nexport const ProjectCreateSchema = ProjectSchema.omit({\n createdAt: true,\n latestBuildId: true,\n updatedAt: true,\n});\n\nexport type ProjectUpdateType = z.infer<typeof ProjectUpdateSchema>;\nexport const ProjectUpdateSchema = ProjectSchema.omit({\n createdAt: true,\n gitHubDefaultBranch: true,\n id: true,\n updatedAt: true,\n})\n .extend({ gitHubDefaultBranch: z.string() })\n .partial();\n\nexport type ProjectsListResultType = z.infer<typeof ProjectsListResultSchema>;\nexport const ProjectsListResultSchema = z.object({\n projects: ProjectSchema.array(),\n});\n\nexport type ProjectGetResultType = z.infer<typeof ProjectGetResultSchema>;\nexport const ProjectGetResultSchema = z.object({\n project: ProjectSchema,\n});\n"],"mappings":";;;;;AAQA,MAAa,gBAAgB,EAC1B,OAAO;CACN,WAAW,EAAE,IAAI,UAAU,CAAC,yBAAQ,IAAI,MAAM,EAAC,aAAa,CAAC;CAE7D,qBAAqB,EAClB,QAAQ,CACR,QAAQ,sBAAsB,CAC9B,KAAK,EAAE,aAAa,+CAA+C,CAAC;CACvE,YAAY,EAAE,QAAQ,CAAC,UAAU,CAAC,KAAK,EACrC,aAAa,kEACd,CAAC;CACF,kBAAkB,EAAE,QAAQ,CAAC,MAC3B,EAAE,UAAU,GAAG,wCAAwC,EACvD,EAAE,QACC,QAAQ,IAAI,MAAM,IAAI,CAAC,WAAW,GACnC,iEACD,CACF;CAED,IAAI;CAEJ,YAAY,EAAE,MAAM,CAAC,EAAE,KAAK,CAAC,UAAU,EAAE,EAAE,QAAQ,GAAG,CAAC,CAAC;CAExD,eAAe,EAAE,MAAM,CAAC,cAAc,UAAU,EAAE,EAAE,QAAQ,GAAG,CAAC,CAAC;CAEjE,MAAM,EAAE,QAAQ,CAAC,KAAK,EAAE,aAAa,wBAAwB,CAAC;CAE9D,sBAAsB,EAAE,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC,QAAQ,yBAAyB,CAAC,KAAK,EACpF,aAAa,gEACd,CAAC;CAEF,WAAW,EAAE,IAAI,UAAU,CAAC,yBAAQ,IAAI,MAAM,EAAC,aAAa,CAAC;CAC9D,CAAC,CACD,KAAK;CAAE,IAAI;CAAW,OAAO;CAAuB,CAAC;AAGxD,MAAa,sBAAsB,cAAc,KAAK;CACpD,WAAW;CACX,eAAe;CACf,WAAW;CACZ,CAAC;AAGF,MAAa,sBAAsB,cAAc,KAAK;CACpD,WAAW;CACX,qBAAqB;CACrB,IAAI;CACJ,WAAW;CACZ,CAAC,CACC,OAAO,EAAE,qBAAqB,EAAE,QAAQ,EAAE,CAAC,CAC3C,SAAS;AAGZ,MAAa,2BAA2B,EAAE,OAAO,EAC/C,UAAU,cAAc,OAAO,EAChC,CAAC;AAGF,MAAa,yBAAyB,EAAE,OAAO,EAC7C,SAAS,eACV,CAAC"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { generateDatabaseCollectionId } from "../utils/adapter-utils.mjs";
|
|
2
|
+
import { checkAuthorisation } from "../utils/auth.mjs";
|
|
3
|
+
import { TagSchema } from "./tags-schema.mjs";
|
|
4
|
+
import { Model } from "./~model.mjs";
|
|
5
|
+
import { ProjectsModel } from "./projects-model.mjs";
|
|
6
|
+
import { BuildsModel } from "./builds-model.mjs";
|
|
7
|
+
import { HTTPException } from "hono/http-exception";
|
|
8
|
+
|
|
9
|
+
//#region src/models/tags-model.ts
|
|
10
|
+
var TagsModel = class TagsModel extends Model {
|
|
11
|
+
constructor(projectId) {
|
|
12
|
+
super(projectId, generateDatabaseCollectionId(projectId, "Tags"));
|
|
13
|
+
}
|
|
14
|
+
async list(options = {}) {
|
|
15
|
+
this.log("List tags...");
|
|
16
|
+
const items = await this.database.listDocuments(this.collectionId, options, this.dbOptions);
|
|
17
|
+
return TagSchema.array().parse(items);
|
|
18
|
+
}
|
|
19
|
+
async create(data, withBuild = false) {
|
|
20
|
+
this.log("Create tag '%s'...", data.value);
|
|
21
|
+
const id = TagsModel.createId(data.value);
|
|
22
|
+
try {
|
|
23
|
+
if (await this.has(id)) throw new HTTPException(409, { message: `Tag '${id}' already exists.` });
|
|
24
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
25
|
+
const tag = {
|
|
26
|
+
...data,
|
|
27
|
+
buildsCount: withBuild ? 1 : 0,
|
|
28
|
+
createdAt: now,
|
|
29
|
+
id,
|
|
30
|
+
updatedAt: now
|
|
31
|
+
};
|
|
32
|
+
await this.database.createDocument(this.collectionId, tag, this.dbOptions);
|
|
33
|
+
return tag;
|
|
34
|
+
} catch (error) {
|
|
35
|
+
throw new HTTPException(500, {
|
|
36
|
+
cause: error,
|
|
37
|
+
message: `Failed to create tag '${id}'.`
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
async get(id) {
|
|
42
|
+
this.log("Get tag '%s'...", id);
|
|
43
|
+
const item = await this.database.getDocument(this.collectionId, id, this.dbOptions);
|
|
44
|
+
return TagSchema.parse(item);
|
|
45
|
+
}
|
|
46
|
+
async has(id) {
|
|
47
|
+
this.log("Check tag '%s'...", id);
|
|
48
|
+
try {
|
|
49
|
+
return await this.database.hasDocument(this.collectionId, id, this.dbOptions);
|
|
50
|
+
} catch {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
async update(id, data) {
|
|
55
|
+
this.log("Update tag '%s'...", id);
|
|
56
|
+
await this.database.updateDocument(this.collectionId, id, {
|
|
57
|
+
...data,
|
|
58
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
59
|
+
}, this.dbOptions);
|
|
60
|
+
}
|
|
61
|
+
async delete(id) {
|
|
62
|
+
this.log("Delete tag '%s'...", id);
|
|
63
|
+
const { gitHubDefaultBranch } = await new ProjectsModel().get(this.projectId);
|
|
64
|
+
if (id === TagsModel.createId(gitHubDefaultBranch)) {
|
|
65
|
+
const message = `Cannot delete the tag associated with default branch (${gitHubDefaultBranch}) of the project '${this.projectId}'.`;
|
|
66
|
+
this.error(message);
|
|
67
|
+
throw new Error(message);
|
|
68
|
+
}
|
|
69
|
+
await this.database.deleteDocument(this.collectionId, id, this.dbOptions);
|
|
70
|
+
try {
|
|
71
|
+
this.debug("Delete builds associated with tag '%s'...", id);
|
|
72
|
+
await new BuildsModel(this.projectId).deleteByTag(id, false);
|
|
73
|
+
} catch (error) {
|
|
74
|
+
this.error("Error deleting builds associated with tag:", error);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
checkAuth = (action) => {
|
|
78
|
+
return checkAuthorisation({
|
|
79
|
+
action,
|
|
80
|
+
projectId: this.projectId,
|
|
81
|
+
resource: "tag"
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
id = (id) => {
|
|
85
|
+
return {
|
|
86
|
+
checkAuth: (action) => checkAuthorisation({
|
|
87
|
+
action,
|
|
88
|
+
projectId: this.projectId,
|
|
89
|
+
resource: "tag"
|
|
90
|
+
}),
|
|
91
|
+
delete: this.delete.bind(this, id),
|
|
92
|
+
get: this.get.bind(this, id),
|
|
93
|
+
has: this.has.bind(this, id),
|
|
94
|
+
id,
|
|
95
|
+
update: this.update.bind(this, id)
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
static createId(value) {
|
|
99
|
+
return value.trim().toLowerCase().replace(/\W+/, "-");
|
|
100
|
+
}
|
|
101
|
+
static guessType(id) {
|
|
102
|
+
if (/^\d+$/.test(id)) return "pr";
|
|
103
|
+
if (/^\w+-\d+$/.test(id)) return "jira";
|
|
104
|
+
return "branch";
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
//#endregion
|
|
109
|
+
export { TagsModel };
|
|
110
|
+
//# sourceMappingURL=tags-model.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tags-model.mjs","names":["tag: TagType"],"sources":["../../src/models/tags-model.ts"],"sourcesContent":["import { HTTPException } from \"hono/http-exception\";\nimport type { StoryBookerPermissionAction } from \"../adapters/_internal/auth.ts\";\nimport { generateDatabaseCollectionId } from \"../utils/adapter-utils.ts\";\nimport { checkAuthorisation } from \"../utils/auth.ts\";\nimport { BuildsModel } from \"./builds-model.ts\";\nimport { ProjectsModel } from \"./projects-model.ts\";\nimport { TagSchema, type TagCreateType, type TagType, type TagUpdateType } from \"./tags-schema.ts\";\nimport { Model, type BaseModel, type ListOptions } from \"./~model.ts\";\n\nexport class TagsModel extends Model<TagType> {\n constructor(projectId: string) {\n super(projectId, generateDatabaseCollectionId(projectId, \"Tags\"));\n }\n\n async list(options: ListOptions<TagType> = {}): Promise<TagType[]> {\n this.log(\"List tags...\");\n\n const items = await this.database.listDocuments(this.collectionId, options, this.dbOptions);\n\n return TagSchema.array().parse(items);\n }\n\n async create(data: TagCreateType, withBuild = false): Promise<TagType> {\n this.log(\"Create tag '%s'...\", data.value);\n const id = TagsModel.createId(data.value);\n\n try {\n if (await this.has(id)) {\n throw new HTTPException(409, {\n message: `Tag '${id}' already exists.`,\n });\n }\n\n const now = new Date().toISOString();\n const tag: TagType = {\n ...data,\n buildsCount: withBuild ? 1 : 0,\n createdAt: now,\n id: id,\n updatedAt: now,\n };\n await this.database.createDocument(this.collectionId, tag, this.dbOptions);\n\n return tag;\n } catch (error) {\n throw new HTTPException(500, {\n cause: error,\n message: `Failed to create tag '${id}'.`,\n });\n }\n }\n\n async get(id: string): Promise<TagType> {\n this.log(\"Get tag '%s'...\", id);\n\n const item = await this.database.getDocument(this.collectionId, id, this.dbOptions);\n\n return TagSchema.parse(item);\n }\n\n async has(id: string): Promise<boolean> {\n this.log(\"Check tag '%s'...\", id);\n try {\n return await this.database.hasDocument(this.collectionId, id, this.dbOptions);\n } catch {\n return false;\n }\n }\n\n async update(id: string, data: TagUpdateType): Promise<void> {\n this.log(\"Update tag '%s'...\", id);\n\n await this.database.updateDocument(\n this.collectionId,\n id,\n { ...data, updatedAt: new Date().toISOString() },\n this.dbOptions,\n );\n }\n\n async delete(id: string): Promise<void> {\n this.log(\"Delete tag '%s'...\", id);\n\n const { gitHubDefaultBranch } = await new ProjectsModel().get(this.projectId);\n if (id === TagsModel.createId(gitHubDefaultBranch)) {\n const message = `Cannot delete the tag associated with default branch (${gitHubDefaultBranch}) of the project '${this.projectId}'.`;\n this.error(message);\n throw new Error(message);\n }\n\n await this.database.deleteDocument(this.collectionId, id, this.dbOptions);\n\n try {\n this.debug(\"Delete builds associated with tag '%s'...\", id);\n await new BuildsModel(this.projectId).deleteByTag(id, false);\n } catch (error) {\n this.error(\"Error deleting builds associated with tag:\", error);\n }\n }\n\n checkAuth = (action: StoryBookerPermissionAction): boolean => {\n return checkAuthorisation({\n action,\n projectId: this.projectId,\n resource: \"tag\",\n });\n };\n\n id: BaseModel<TagType>[\"id\"] = (id: string) => {\n return {\n checkAuth: (action) =>\n checkAuthorisation({\n action,\n projectId: this.projectId,\n resource: \"tag\",\n }),\n delete: this.delete.bind(this, id),\n get: this.get.bind(this, id),\n has: this.has.bind(this, id),\n id,\n update: this.update.bind(this, id),\n };\n };\n\n static createId(value: string): string {\n return value.trim().toLowerCase().replace(/\\W+/, \"-\");\n }\n\n static guessType(id: string): TagType[\"type\"] {\n if (/^\\d+$/.test(id)) {\n return \"pr\";\n }\n if (/^\\w+-\\d+$/.test(id)) {\n return \"jira\";\n }\n return \"branch\";\n }\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { TagTypes } from "../~internal/constants.mjs";
|
|
2
|
+
import "./~shared-schema.mjs";
|
|
3
|
+
import { z } from "@hono/zod-openapi";
|
|
4
|
+
|
|
5
|
+
//#region src/models/tags-schema.d.ts
|
|
6
|
+
type TagVariant = (typeof TagTypes)[number];
|
|
7
|
+
type TagType = z.infer<typeof TagSchema>;
|
|
8
|
+
declare const TagSchema: z.ZodObject<{
|
|
9
|
+
buildsCount: z.ZodDefault<z.ZodNumber>;
|
|
10
|
+
createdAt: z.ZodDefault<z.ZodISODateTime>;
|
|
11
|
+
id: z.ZodString;
|
|
12
|
+
latestBuildId: z.ZodUnion<readonly [z.ZodOptional<z.ZodString>, z.ZodLiteral<"">]>;
|
|
13
|
+
type: z.ZodEnum<{
|
|
14
|
+
branch: "branch";
|
|
15
|
+
jira: "jira";
|
|
16
|
+
pr: "pr";
|
|
17
|
+
}>;
|
|
18
|
+
updatedAt: z.ZodDefault<z.ZodISODateTime>;
|
|
19
|
+
value: z.ZodString;
|
|
20
|
+
}, z.core.$strip>;
|
|
21
|
+
type TagCreateType = z.infer<typeof TagCreateSchema>;
|
|
22
|
+
declare const TagCreateSchema: z.ZodObject<{
|
|
23
|
+
latestBuildId: z.ZodUnion<readonly [z.ZodOptional<z.ZodString>, z.ZodLiteral<"">]>;
|
|
24
|
+
type: z.ZodEnum<{
|
|
25
|
+
branch: "branch";
|
|
26
|
+
jira: "jira";
|
|
27
|
+
pr: "pr";
|
|
28
|
+
}>;
|
|
29
|
+
value: z.ZodString;
|
|
30
|
+
}, z.core.$strip>;
|
|
31
|
+
type TagUpdateType = z.infer<typeof TagUpdateSchema>;
|
|
32
|
+
declare const TagUpdateSchema: z.ZodObject<{
|
|
33
|
+
buildsCount: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
34
|
+
latestBuildId: z.ZodOptional<z.ZodUnion<readonly [z.ZodOptional<z.ZodString>, z.ZodLiteral<"">]>>;
|
|
35
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
36
|
+
branch: "branch";
|
|
37
|
+
jira: "jira";
|
|
38
|
+
pr: "pr";
|
|
39
|
+
}>>;
|
|
40
|
+
value: z.ZodOptional<z.ZodString>;
|
|
41
|
+
}, z.core.$strip>;
|
|
42
|
+
type TagsListResultType = z.infer<typeof TagsListResultSchema>;
|
|
43
|
+
declare const TagsListResultSchema: z.ZodObject<{
|
|
44
|
+
tags: z.ZodArray<z.ZodObject<{
|
|
45
|
+
buildsCount: z.ZodDefault<z.ZodNumber>;
|
|
46
|
+
createdAt: z.ZodDefault<z.ZodISODateTime>;
|
|
47
|
+
id: z.ZodString;
|
|
48
|
+
latestBuildId: z.ZodUnion<readonly [z.ZodOptional<z.ZodString>, z.ZodLiteral<"">]>;
|
|
49
|
+
type: z.ZodEnum<{
|
|
50
|
+
branch: "branch";
|
|
51
|
+
jira: "jira";
|
|
52
|
+
pr: "pr";
|
|
53
|
+
}>;
|
|
54
|
+
updatedAt: z.ZodDefault<z.ZodISODateTime>;
|
|
55
|
+
value: z.ZodString;
|
|
56
|
+
}, z.core.$strip>>;
|
|
57
|
+
}, z.core.$strip>;
|
|
58
|
+
type TagsGetResultType = z.infer<typeof TagsGetResultSchema>;
|
|
59
|
+
declare const TagsGetResultSchema: z.ZodObject<{
|
|
60
|
+
tag: z.ZodObject<{
|
|
61
|
+
buildsCount: z.ZodDefault<z.ZodNumber>;
|
|
62
|
+
createdAt: z.ZodDefault<z.ZodISODateTime>;
|
|
63
|
+
id: z.ZodString;
|
|
64
|
+
latestBuildId: z.ZodUnion<readonly [z.ZodOptional<z.ZodString>, z.ZodLiteral<"">]>;
|
|
65
|
+
type: z.ZodEnum<{
|
|
66
|
+
branch: "branch";
|
|
67
|
+
jira: "jira";
|
|
68
|
+
pr: "pr";
|
|
69
|
+
}>;
|
|
70
|
+
updatedAt: z.ZodDefault<z.ZodISODateTime>;
|
|
71
|
+
value: z.ZodString;
|
|
72
|
+
}, z.core.$strip>;
|
|
73
|
+
}, z.core.$strip>;
|
|
74
|
+
//#endregion
|
|
75
|
+
export { TagCreateType, TagType, TagUpdateType, TagVariant, TagsGetResultType, TagsListResultType };
|
|
76
|
+
//# sourceMappingURL=tags-schema.d.mts.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { TagTypes } from "../~internal/constants.mjs";
|
|
2
|
+
import { BuildIdSchema, TagIdSchema } from "./~shared-schema.mjs";
|
|
3
|
+
import { z } from "@hono/zod-openapi";
|
|
4
|
+
|
|
5
|
+
//#region src/models/tags-schema.ts
|
|
6
|
+
const TagSchema = z.object({
|
|
7
|
+
buildsCount: z.number().default(0),
|
|
8
|
+
createdAt: z.iso.datetime().default((/* @__PURE__ */ new Date()).toISOString()),
|
|
9
|
+
id: TagIdSchema,
|
|
10
|
+
latestBuildId: z.union([BuildIdSchema.optional(), z.literal("")]),
|
|
11
|
+
type: z.enum(TagTypes),
|
|
12
|
+
updatedAt: z.iso.datetime().default((/* @__PURE__ */ new Date()).toISOString()),
|
|
13
|
+
value: z.string().meta({ description: "The value of the tag." })
|
|
14
|
+
}).meta({
|
|
15
|
+
id: "Tag",
|
|
16
|
+
title: "StoryBooker Tag"
|
|
17
|
+
});
|
|
18
|
+
const TagCreateSchema = TagSchema.omit({
|
|
19
|
+
buildsCount: true,
|
|
20
|
+
createdAt: true,
|
|
21
|
+
id: true,
|
|
22
|
+
updatedAt: true
|
|
23
|
+
});
|
|
24
|
+
const TagUpdateSchema = TagSchema.omit({
|
|
25
|
+
createdAt: true,
|
|
26
|
+
id: true,
|
|
27
|
+
updatedAt: true
|
|
28
|
+
}).partial();
|
|
29
|
+
const TagsListResultSchema = z.object({ tags: TagSchema.array() });
|
|
30
|
+
const TagsGetResultSchema = z.object({ tag: TagSchema });
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
export { TagCreateSchema, TagSchema, TagUpdateSchema, TagsGetResultSchema, TagsListResultSchema };
|
|
34
|
+
//# sourceMappingURL=tags-schema.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tags-schema.mjs","names":[],"sources":["../../src/models/tags-schema.ts"],"sourcesContent":["import { z } from \"@hono/zod-openapi\";\nimport { TagTypes } from \"../utils/constants.ts\";\nimport { BuildIdSchema, TagIdSchema } from \"./~shared-schema.ts\";\n\nexport { TagIdSchema, TagTypes };\n\nexport type TagVariant = (typeof TagTypes)[number];\n\nexport type TagType = z.infer<typeof TagSchema>;\nexport const TagSchema = z\n .object({\n buildsCount: z.number().default(0),\n createdAt: z.iso.datetime().default(new Date().toISOString()),\n id: TagIdSchema,\n latestBuildId: z.union([BuildIdSchema.optional(), z.literal(\"\")]),\n type: z.enum(TagTypes),\n updatedAt: z.iso.datetime().default(new Date().toISOString()),\n value: z.string().meta({ description: \"The value of the tag.\" }),\n })\n .meta({ id: \"Tag\", title: \"StoryBooker Tag\" });\n\nexport type TagCreateType = z.infer<typeof TagCreateSchema>;\nexport const TagCreateSchema = TagSchema.omit({\n buildsCount: true,\n createdAt: true,\n id: true,\n\n updatedAt: true,\n});\n\nexport type TagUpdateType = z.infer<typeof TagUpdateSchema>;\nexport const TagUpdateSchema = TagSchema.omit({\n createdAt: true,\n id: true,\n updatedAt: true,\n}).partial();\n\nexport type TagsListResultType = z.infer<typeof TagsListResultSchema>;\nexport const TagsListResultSchema = z.object({\n tags: TagSchema.array(),\n});\nexport type TagsGetResultType = z.infer<typeof TagsGetResultSchema>;\nexport const TagsGetResultSchema = z.object({\n tag: TagSchema,\n});\n"],"mappings":";;;;;AASA,MAAa,YAAY,EACtB,OAAO;CACN,aAAa,EAAE,QAAQ,CAAC,QAAQ,EAAE;CAClC,WAAW,EAAE,IAAI,UAAU,CAAC,yBAAQ,IAAI,MAAM,EAAC,aAAa,CAAC;CAC7D,IAAI;CACJ,eAAe,EAAE,MAAM,CAAC,cAAc,UAAU,EAAE,EAAE,QAAQ,GAAG,CAAC,CAAC;CACjE,MAAM,EAAE,KAAK,SAAS;CACtB,WAAW,EAAE,IAAI,UAAU,CAAC,yBAAQ,IAAI,MAAM,EAAC,aAAa,CAAC;CAC7D,OAAO,EAAE,QAAQ,CAAC,KAAK,EAAE,aAAa,yBAAyB,CAAC;CACjE,CAAC,CACD,KAAK;CAAE,IAAI;CAAO,OAAO;CAAmB,CAAC;AAGhD,MAAa,kBAAkB,UAAU,KAAK;CAC5C,aAAa;CACb,WAAW;CACX,IAAI;CAEJ,WAAW;CACZ,CAAC;AAGF,MAAa,kBAAkB,UAAU,KAAK;CAC5C,WAAW;CACX,IAAI;CACJ,WAAW;CACZ,CAAC,CAAC,SAAS;AAGZ,MAAa,uBAAuB,EAAE,OAAO,EAC3C,MAAM,UAAU,OAAO,EACxB,CAAC;AAEF,MAAa,sBAAsB,EAAE,OAAO,EAC1C,KAAK,WACN,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { getStore } from "../utils/store.mjs";
|
|
2
|
+
import { parseErrorMessage } from "../utils/error.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/models/~model.ts
|
|
5
|
+
var Model = class {
|
|
6
|
+
projectId;
|
|
7
|
+
collectionId;
|
|
8
|
+
database;
|
|
9
|
+
storage;
|
|
10
|
+
logger;
|
|
11
|
+
dbOptions;
|
|
12
|
+
storageOptions;
|
|
13
|
+
constructor(projectId, collectionId) {
|
|
14
|
+
const { abortSignal, database, storage, logger } = getStore();
|
|
15
|
+
this.projectId = projectId ?? "";
|
|
16
|
+
this.collectionId = collectionId;
|
|
17
|
+
this.database = database;
|
|
18
|
+
this.storage = storage;
|
|
19
|
+
this.logger = logger;
|
|
20
|
+
this.dbOptions = {
|
|
21
|
+
abortSignal,
|
|
22
|
+
logger
|
|
23
|
+
};
|
|
24
|
+
this.storageOptions = {
|
|
25
|
+
abortSignal,
|
|
26
|
+
logger
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
log(message, ...args) {
|
|
30
|
+
this.logger.log(`[Model:${this.projectId || "All"}] ${message}`, ...args);
|
|
31
|
+
}
|
|
32
|
+
debug(message, ...args) {
|
|
33
|
+
this.logger.debug?.(`[Model:${this.projectId || "All"}] ${message}`, ...args);
|
|
34
|
+
}
|
|
35
|
+
error(error, ...args) {
|
|
36
|
+
const { errorMessage } = parseErrorMessage(error);
|
|
37
|
+
this.logger.error(`[Model:${this.projectId || "All"}] Error:`, errorMessage, ...args);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
export { Model };
|
|
43
|
+
//# sourceMappingURL=~model.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"~model.mjs","names":[],"sources":["../../src/models/~model.ts"],"sourcesContent":["import type {\n DatabaseAdapter,\n DatabaseAdapterOptions,\n LoggerAdapter,\n StorageAdapter,\n StorageAdapterOptions,\n StoryBookerDatabaseDocument,\n StoryBookerPermissionAction,\n} from \"../adapters/_internal/index.ts\";\nimport { parseErrorMessage } from \"../utils/error.ts\";\nimport { getStore } from \"../utils/store.ts\";\n\nexport interface ListOptions<Item extends Record<string, unknown>> {\n limit?: number;\n filter?: string | ((item: Item) => boolean);\n select?: string[];\n sort?: \"latest\" | ((item1: Item, item2: Item) => number);\n}\n\nexport abstract class Model<Data extends StoryBookerDatabaseDocument> implements BaseModel<Data> {\n projectId: string;\n collectionId: string;\n database: DatabaseAdapter<Data>;\n storage: StorageAdapter;\n logger: LoggerAdapter;\n dbOptions: DatabaseAdapterOptions;\n storageOptions: StorageAdapterOptions;\n\n constructor(projectId: string | null, collectionId: string) {\n const { abortSignal, database, storage, logger } = getStore();\n this.projectId = projectId ?? \"\";\n this.collectionId = collectionId;\n this.database = database as unknown as DatabaseAdapter<Data>;\n this.storage = storage;\n this.logger = logger;\n this.dbOptions = { abortSignal, logger };\n this.storageOptions = { abortSignal, logger };\n }\n\n log(message: string, ...args: unknown[]): void {\n this.logger.log(`[Model:${this.projectId || \"All\"}] ${message}`, ...args);\n }\n debug(message: string, ...args: unknown[]): void {\n this.logger.debug?.(`[Model:${this.projectId || \"All\"}] ${message}`, ...args);\n }\n error(error: unknown, ...args: unknown[]): void {\n const { errorMessage } = parseErrorMessage(error);\n this.logger.error(`[Model:${this.projectId || \"All\"}] Error:`, errorMessage, ...args);\n }\n\n abstract list(options?: ListOptions<Data>): Promise<Data[]>;\n abstract create(data: unknown): Promise<Data>;\n abstract get(id: string): Promise<Data>;\n abstract has(id: string): Promise<boolean>;\n abstract update(id: string, data: unknown): Promise<void>;\n abstract delete(id: string): Promise<void>;\n abstract id: (id: string) => BaseIdModel<Data>;\n abstract checkAuth(action: StoryBookerPermissionAction): boolean;\n}\n\nexport interface BaseModel<Data extends StoryBookerDatabaseDocument> {\n list(options?: ListOptions<Data>): Promise<Data[]>;\n create(data: unknown): Promise<Data>;\n get(id: string): Promise<Data>;\n has(id: string): Promise<boolean>;\n update(id: string, data: unknown): Promise<void>;\n delete(id: string): Promise<void>;\n checkAuth(action: StoryBookerPermissionAction): boolean;\n id: (id: string) => BaseIdModel<Data>;\n}\n\nexport interface BaseIdModel<Data extends StoryBookerDatabaseDocument> {\n id: string;\n get(): Promise<Data>;\n has(): Promise<boolean>;\n update(data: unknown): Promise<void>;\n delete(): Promise<void>;\n checkAuth(action: StoryBookerPermissionAction): boolean;\n}\n"],"mappings":";;;;AAmBA,IAAsB,QAAtB,MAAiG;CAC/F;CACA;CACA;CACA;CACA;CACA;CACA;CAEA,YAAY,WAA0B,cAAsB;EAC1D,MAAM,EAAE,aAAa,UAAU,SAAS,WAAW,UAAU;AAC7D,OAAK,YAAY,aAAa;AAC9B,OAAK,eAAe;AACpB,OAAK,WAAW;AAChB,OAAK,UAAU;AACf,OAAK,SAAS;AACd,OAAK,YAAY;GAAE;GAAa;GAAQ;AACxC,OAAK,iBAAiB;GAAE;GAAa;GAAQ;;CAG/C,IAAI,SAAiB,GAAG,MAAuB;AAC7C,OAAK,OAAO,IAAI,UAAU,KAAK,aAAa,MAAM,IAAI,WAAW,GAAG,KAAK;;CAE3E,MAAM,SAAiB,GAAG,MAAuB;AAC/C,OAAK,OAAO,QAAQ,UAAU,KAAK,aAAa,MAAM,IAAI,WAAW,GAAG,KAAK;;CAE/E,MAAM,OAAgB,GAAG,MAAuB;EAC9C,MAAM,EAAE,iBAAiB,kBAAkB,MAAM;AACjD,OAAK,OAAO,MAAM,UAAU,KAAK,aAAa,MAAM,WAAW,cAAc,GAAG,KAAK"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import { z } from "@hono/zod-openapi";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { PATTERNS } from "../~internal/constants.mjs";
|
|
2
|
+
import { z } from "@hono/zod-openapi";
|
|
3
|
+
|
|
4
|
+
//#region src/models/~shared-schema.ts
|
|
5
|
+
const TagIdSchema = z.string().meta({
|
|
6
|
+
description: "The ID of the tag.",
|
|
7
|
+
id: "TagID"
|
|
8
|
+
});
|
|
9
|
+
const BuildIdSchema = z.string().check(z.minLength(7)).meta({
|
|
10
|
+
description: "The ID of the build.",
|
|
11
|
+
id: "BuildID"
|
|
12
|
+
});
|
|
13
|
+
const ProjectIdSchema = z.string().refine((val) => new RegExp(PATTERNS.projectId.pattern).test(val), PATTERNS.projectId.message).meta({
|
|
14
|
+
description: "The ID of the project.",
|
|
15
|
+
id: "ProjectID"
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
export { BuildIdSchema, ProjectIdSchema, TagIdSchema };
|
|
20
|
+
//# sourceMappingURL=~shared-schema.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"~shared-schema.mjs","names":[],"sources":["../../src/models/~shared-schema.ts"],"sourcesContent":["import { z } from \"@hono/zod-openapi\";\nimport { PATTERNS } from \"../utils/constants.ts\";\n\nexport const TagIdSchema = z.string().meta({ description: \"The ID of the tag.\", id: \"TagID\" });\n\nexport const BuildIdSchema = z\n .string()\n .check(z.minLength(7))\n .meta({ description: \"The ID of the build.\", id: \"BuildID\" });\n\nexport const ProjectIdSchema = z\n .string()\n .refine((val) => new RegExp(PATTERNS.projectId.pattern).test(val), PATTERNS.projectId.message)\n .meta({ description: \"The ID of the project.\", id: \"ProjectID\" });\n"],"mappings":";;;;AAGA,MAAa,cAAc,EAAE,QAAQ,CAAC,KAAK;CAAE,aAAa;CAAsB,IAAI;CAAS,CAAC;AAE9F,MAAa,gBAAgB,EAC1B,QAAQ,CACR,MAAM,EAAE,UAAU,EAAE,CAAC,CACrB,KAAK;CAAE,aAAa;CAAwB,IAAI;CAAW,CAAC;AAE/D,MAAa,kBAAkB,EAC5B,QAAQ,CACR,QAAQ,QAAQ,IAAI,OAAO,SAAS,UAAU,QAAQ,CAAC,KAAK,IAAI,EAAE,SAAS,UAAU,QAAQ,CAC7F,KAAK;CAAE,aAAa;CAA0B,IAAI;CAAa,CAAC"}
|
package/dist/mysql.d.mts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { DatabaseAdapter } from "./~internal/adapter/database.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/adapters/mysql.d.ts
|
|
4
|
+
interface MySQLConnection {
|
|
5
|
+
connect?(): Promise<void>;
|
|
6
|
+
execute<Data>(query: string, params?: unknown[]): Promise<[Data]>;
|
|
7
|
+
query<Data>(query: string, params?: unknown[]): Promise<[Data]>;
|
|
8
|
+
end?(): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* MySQL database adapter for StoryBooker.
|
|
12
|
+
* Uses tables to represent collections and rows to represent documents.
|
|
13
|
+
*
|
|
14
|
+
* Table structure:
|
|
15
|
+
* - Each collection becomes a table with name: `sb_{collectionId}`
|
|
16
|
+
* - Each table has columns: id (VARCHAR PRIMARY KEY), data (JSON), created_at (TIMESTAMP), updated_at (TIMESTAMP)
|
|
17
|
+
* - Collections metadata stored in `sb_collections` table
|
|
18
|
+
*
|
|
19
|
+
* Compatible with mysql2, mysql, and other MySQL libraries that implement the connection interface.
|
|
20
|
+
*/
|
|
21
|
+
declare class MySQLDatabaseAdapter implements DatabaseAdapter {
|
|
22
|
+
#private;
|
|
23
|
+
constructor(connection: MySQLConnection, tablePrefix?: string);
|
|
24
|
+
metadata: DatabaseAdapter["metadata"];
|
|
25
|
+
init: DatabaseAdapter["init"];
|
|
26
|
+
listCollections: DatabaseAdapter["listCollections"];
|
|
27
|
+
createCollection: DatabaseAdapter["createCollection"];
|
|
28
|
+
hasCollection: DatabaseAdapter["hasCollection"];
|
|
29
|
+
deleteCollection: DatabaseAdapter["deleteCollection"];
|
|
30
|
+
listDocuments: DatabaseAdapter["listDocuments"];
|
|
31
|
+
getDocument: DatabaseAdapter["getDocument"];
|
|
32
|
+
hasDocument: DatabaseAdapter["hasDocument"];
|
|
33
|
+
createDocument: DatabaseAdapter["createDocument"];
|
|
34
|
+
updateDocument: DatabaseAdapter["updateDocument"];
|
|
35
|
+
deleteDocument: DatabaseAdapter["deleteDocument"];
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
export { MySQLConnection, MySQLDatabaseAdapter };
|
|
39
|
+
//# sourceMappingURL=mysql.d.mts.map
|