storybooker 0.19.4 → 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":"database.mjs","names":[],"sources":["../../../src/adapters/_internal/database.ts"],"sourcesContent":["// oxlint-disable max-classes-per-file\n\nimport { HTTPException } from \"hono/http-exception\";\nimport type { ContentfulStatusCode } from \"hono/utils/http-status\";\nimport type { StoryBookerAdapterMetadata } from \"../../utils/adapter-utils.ts\";\nimport type { LoggerAdapter } from \"./logger.ts\";\n\n/**\n * Service adapter to interact with database.\n *\n * @description\n * The adapter should provide callbacks to CRUD operations\n * to an existing database.\n *\n * - `collection`: A collection/container/table to hold items.\n * - `document`: A single entry in collection which contains key-value pairs (no nested data).\n * Each document has a key 'id` which is unique in the collection.\n *\n * @throws {DatabaseNotInitializedError} if the DB service is not connected.\n * @throws {CollectionAlreadyExistsError} if the collection already exists.\n * @throws {CollectionDoesNotExistError} if the collection does not exist.\n * @throws {DocumentAlreadyExistsError} if the document already exists in the collection.\n * @throws {DocumentDoesNotExistError} if the document does not exist in the collection.\n * @throws {CustomError} if some other error occurs.\n */\nexport interface DatabaseAdapter<\n DbDocument extends StoryBookerDatabaseDocument = StoryBookerDatabaseDocument,\n> {\n /**\n * Metadata about the adapter.\n */\n metadata: StoryBookerAdapterMetadata;\n\n /**\n * An optional method that is called on app boot-up\n * to run async setup functions.\n * @param options Common options like abortSignal.\n * @throws if an error occur during initialisation.\n */\n init?: (options: DatabaseAdapterOptions) => Promise<void>;\n\n // Collections (group of items. aka Tables)\n\n /**\n * List all collections available in the DB.\n * @param options Common options like abortSignal.\n * @returns A list of names/IDs of the collections.\n * @throws {DatabaseNotInitializedError} if the DB service is not connected.\n */\n listCollections: (options: DatabaseAdapterOptions) => Promise<string[]>;\n\n /**\n * Create a collection used for different projects.\n * @param collectionId ID of the collection\n * @param options Common options like abortSignal.\n * @throws {DatabaseNotInitializedError} if the DB service is not connected.\n * @throws {CollectionAlreadyExistsError} if collection with ID already exists.\n */\n createCollection: (collectionId: string, options: DatabaseAdapterOptions) => Promise<void>;\n\n /**\n * Delete an existing collection.\n * @param collectionId ID of the collection\n * @param options Common options like abortSignal.\n * @throws {DatabaseNotInitializedError} if the DB service is not connected.\n * @throws {CollectionDoesNotExistError} if collection with ID does not exist.\n */\n deleteCollection: (collectionId: string, options: DatabaseAdapterOptions) => Promise<void>;\n\n /**\n * Check if collection exists.\n * @param collectionId ID of the collection\n * @param options Common options like abortSignal.\n * @returns if collection is available of not\n * @throws never.\n */\n hasCollection: (collectionId: string, options: DatabaseAdapterOptions) => Promise<boolean>;\n\n // Documents (items, entries, rows, etc)\n\n /**\n * List all documents available in the requested collection.\n * @param collectionId ID of the collection\n * @param listOptions Options to format/sort the result\n * @param options Common options like abortSignal.\n * @returns List of documents\n * @throws if the collection does not exist.\n */\n listDocuments: (\n collectionId: string,\n listOptions: DatabaseDocumentListOptions<DbDocument>,\n options: DatabaseAdapterOptions,\n ) => Promise<DbDocument[]>;\n\n /**\n * Create a new document in the collection.\n * @param collectionId ID of the collection\n * @param documentData Data to be stored\n * @param options Common options like abortSignal.\n * @throws if the collection does not exist.\n */\n createDocument: (\n collectionId: string,\n documentData: DbDocument,\n options: DatabaseAdapterOptions,\n ) => Promise<void>;\n\n /**\n * Get matching document data available in the requested collection.\n * @param collectionId ID of the collection\n * @param documentId ID of the document\n * @param options Common options like abortSignal.\n * @returns Data of the document\n * @throws if the collection or document does not exist.\n */\n getDocument: (\n collectionId: string,\n documentId: string,\n options: DatabaseAdapterOptions,\n ) => Promise<DbDocument>;\n\n /**\n * Check matching document data available in the requested collection.\n * @param collectionId ID of the collection\n * @param documentId ID of the document\n * @param options Common options like abortSignal.\n * @returns if document is available of not\n * @throws if the collection does not exists.\n */\n hasDocument: (\n collectionId: string,\n documentId: string,\n options: DatabaseAdapterOptions,\n ) => Promise<boolean>;\n\n /**\n * Update matching document data available in the requested collection.\n * @param collectionId ID of the collection\n * @param documentId ID of the document\n * @param documentData Partial data to be updated.\n * @param options Common options like abortSignal.\n * @throws if the collection or document does not exist.\n */\n updateDocument: (\n collectionId: string,\n documentId: string,\n documentData: Partial<Omit<DbDocument, \"id\">>,\n options: DatabaseAdapterOptions,\n ) => Promise<void>;\n\n /**\n * Delete matching document available in the requested collection.\n * @param collectionId ID of the collection\n * @param documentId ID of the document\n * @param options Common options like abortSignal.\n * @throws if the collection or document does not exist.\n */\n deleteDocument: (\n collectionId: string,\n documentId: string,\n options: DatabaseAdapterOptions,\n ) => Promise<void>;\n}\n\n/**\n * Base Document shape used in StoryBooker Database.\n * Should always contain a filed 'id' with string value.\n */\nexport interface StoryBookerDatabaseDocument {\n id: string;\n updatedAt: string;\n createdAt: string;\n [key: string]: unknown;\n}\n\n/** Common Database adapter options. */\nexport interface DatabaseAdapterOptions {\n /** A signal that can be used to cancel the request handling. */\n abortSignal?: AbortSignal;\n /** Logger */\n logger: LoggerAdapter;\n}\n\nexport interface DatabaseDocumentListOptions<Item extends { id: string }> {\n limit?: number;\n filter?: string | ((item: Item) => boolean);\n select?: string[];\n sort?: \"latest\" | ((item1: Item, item2: Item) => number);\n}\n\n/**\n * Pre-defined Database adapter errors\n * that can be used across different adapters.\n *\n * Throws {HTTPException} with relevant status codes.\n */\nexport const DatabaseAdapterErrors = {\n DatabaseNotInitializedError: class extends HTTPException {\n constructor(cause?: unknown) {\n super(500, { cause, message: \"Database adapter is not initialized.\" });\n }\n },\n CollectionAlreadyExistsError: class extends HTTPException {\n constructor(collectionId: string, cause?: unknown) {\n super(409, {\n cause,\n message: `Database collection '${collectionId}' already exists.`,\n });\n }\n },\n CollectionDoesNotExistError: class extends HTTPException {\n constructor(collectionId: string, cause?: unknown) {\n super(404, {\n cause,\n message: `Database collection '${collectionId}' does not exist.`,\n });\n }\n },\n DocumentAlreadyExistsError: class extends HTTPException {\n constructor(collectionId: string, documentId: string, cause?: unknown) {\n super(409, {\n cause,\n message: `Database document '${documentId}' already exists in collection '${collectionId}'.`,\n });\n }\n },\n DocumentDoesNotExistError: class extends HTTPException {\n constructor(collectionId: string, documentId: string, cause?: unknown) {\n super(404, {\n cause,\n message: `Database document '${documentId}' does not exist in collection '${collectionId}'.`,\n });\n }\n },\n CustomError: class extends HTTPException {\n constructor(status: number | undefined, message: string, cause?: unknown) {\n super(status as ContentfulStatusCode, { cause, message });\n }\n },\n // oxlint-disable-next-line no-explicit-any\n} satisfies Record<string, new (...args: any[]) => HTTPException>;\n"],"mappings":";;;;;;;;;AAoMA,MAAa,wBAAwB;CACnC,6BAA6B,cAAc,cAAc;EACvD,YAAY,OAAiB;AAC3B,SAAM,KAAK;IAAE;IAAO,SAAS;IAAwC,CAAC;;;CAG1E,8BAA8B,cAAc,cAAc;EACxD,YAAY,cAAsB,OAAiB;AACjD,SAAM,KAAK;IACT;IACA,SAAS,wBAAwB,aAAa;IAC/C,CAAC;;;CAGN,6BAA6B,cAAc,cAAc;EACvD,YAAY,cAAsB,OAAiB;AACjD,SAAM,KAAK;IACT;IACA,SAAS,wBAAwB,aAAa;IAC/C,CAAC;;;CAGN,4BAA4B,cAAc,cAAc;EACtD,YAAY,cAAsB,YAAoB,OAAiB;AACrE,SAAM,KAAK;IACT;IACA,SAAS,sBAAsB,WAAW,kCAAkC,aAAa;IAC1F,CAAC;;;CAGN,2BAA2B,cAAc,cAAc;EACrD,YAAY,cAAsB,YAAoB,OAAiB;AACrE,SAAM,KAAK;IACT;IACA,SAAS,sBAAsB,WAAW,kCAAkC,aAAa;IAC1F,CAAC;;;CAGN,aAAa,cAAc,cAAc;EACvC,YAAY,QAA4B,SAAiB,OAAiB;AACxE,SAAM,QAAgC;IAAE;IAAO;IAAS,CAAC;;;CAI9D"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { StoryBookerAdapterMetadata } from "../../utils/adapter-utils.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/adapters/_internal/logger.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Service adapter to log to desired destination.
|
|
7
|
+
*
|
|
8
|
+
* The service should contain method to `log` and report `error`.
|
|
9
|
+
* It can optionally have `debug` callback for debug messages.
|
|
10
|
+
*
|
|
11
|
+
* @default NodeJS.console
|
|
12
|
+
*/
|
|
13
|
+
interface LoggerAdapter {
|
|
14
|
+
/**
|
|
15
|
+
* Metadata about the adapter.
|
|
16
|
+
*/
|
|
17
|
+
metadata: StoryBookerAdapterMetadata;
|
|
18
|
+
/**
|
|
19
|
+
* Optional debug logs
|
|
20
|
+
*/
|
|
21
|
+
debug?: (...args: unknown[]) => void;
|
|
22
|
+
/**
|
|
23
|
+
* Error logs
|
|
24
|
+
*/
|
|
25
|
+
error: (...args: unknown[]) => void;
|
|
26
|
+
/**
|
|
27
|
+
* Normal logs
|
|
28
|
+
*/
|
|
29
|
+
log: (...args: unknown[]) => void;
|
|
30
|
+
}
|
|
31
|
+
declare function createConsoleLoggerAdapter(): LoggerAdapter;
|
|
32
|
+
//#endregion
|
|
33
|
+
export { LoggerAdapter, createConsoleLoggerAdapter };
|
|
34
|
+
//# sourceMappingURL=logger.d.mts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/adapters/_internal/logger.ts
|
|
2
|
+
function createConsoleLoggerAdapter() {
|
|
3
|
+
return {
|
|
4
|
+
metadata: { name: "console" },
|
|
5
|
+
debug: console.debug.bind(console),
|
|
6
|
+
error: console.error.bind(console),
|
|
7
|
+
log: console.log.bind(console)
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { createConsoleLoggerAdapter };
|
|
13
|
+
//# sourceMappingURL=logger.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.mjs","names":[],"sources":["../../../src/adapters/_internal/logger.ts"],"sourcesContent":["import type { StoryBookerAdapterMetadata } from \"../../utils/adapter-utils.ts\";\n\n// oxlint-disable no-console\n/**\n * Service adapter to log to desired destination.\n *\n * The service should contain method to `log` and report `error`.\n * It can optionally have `debug` callback for debug messages.\n *\n * @default NodeJS.console\n */\nexport interface LoggerAdapter {\n /**\n * Metadata about the adapter.\n */\n metadata: StoryBookerAdapterMetadata;\n /**\n * Optional debug logs\n */\n debug?: (...args: unknown[]) => void;\n /**\n * Error logs\n */\n error: (...args: unknown[]) => void;\n /**\n * Normal logs\n */\n log: (...args: unknown[]) => void;\n}\n\nexport function createConsoleLoggerAdapter(): LoggerAdapter {\n return {\n metadata: {\n name: \"console\",\n },\n\n debug: console.debug.bind(console),\n error: console.error.bind(console),\n log: console.log.bind(console),\n };\n}\n"],"mappings":";AA8BA,SAAgB,6BAA4C;AAC1D,QAAO;EACL,UAAU,EACR,MAAM,WACP;EAED,OAAO,QAAQ,MAAM,KAAK,QAAQ;EAClC,OAAO,QAAQ,MAAM,KAAK,QAAQ;EAClC,KAAK,QAAQ,IAAI,KAAK,QAAQ;EAC/B"}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { StoryBookerAdapterMetadata } from "../../utils/adapter-utils.mjs";
|
|
2
|
+
import { LoggerAdapter } from "./logger.mjs";
|
|
3
|
+
import { ContentfulStatusCode } from "hono/utils/http-status";
|
|
4
|
+
|
|
5
|
+
//#region src/adapters/_internal/storage.d.ts
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Service adapter to interact with file-storage.
|
|
9
|
+
*
|
|
10
|
+
* @description
|
|
11
|
+
* The adapter should provide callbacks to perform operations
|
|
12
|
+
* to an existing storage like upload and download files.
|
|
13
|
+
*
|
|
14
|
+
* - `container`: A container/group/bucket to hold files. Each project has one container.
|
|
15
|
+
* - `file`: A single binary that can individually stored and retrieved.
|
|
16
|
+
*
|
|
17
|
+
* @throws {StorageNotInitializedError} if the Storage service is not connected.
|
|
18
|
+
* @throws {ContainerAlreadyExistsError} if the container already exists.
|
|
19
|
+
* @throws {ContainerDoesNotExistError} if the container does not exist.
|
|
20
|
+
* @throws {FileDoesNotExistError} if the file does not exist in the container.
|
|
21
|
+
* @throws {CustomError} if some other error occurs.
|
|
22
|
+
*/
|
|
23
|
+
interface StorageAdapter {
|
|
24
|
+
/**
|
|
25
|
+
* Metadata about the adapter.
|
|
26
|
+
*/
|
|
27
|
+
metadata: StoryBookerAdapterMetadata;
|
|
28
|
+
/**
|
|
29
|
+
* An optional method that is called on app boot-up
|
|
30
|
+
* to run async setup functions.
|
|
31
|
+
* @param options Common options like abortSignal.
|
|
32
|
+
* @throws If the Storage service fails to initialize.
|
|
33
|
+
*/
|
|
34
|
+
init?: (options: StorageAdapterOptions) => Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* List all containers available in the storage.
|
|
37
|
+
* @param options Common options like abortSignal.
|
|
38
|
+
* @returns A list of names/IDs of the containers.
|
|
39
|
+
* @throws {StorageNotInitializedError} if the Storage service is not connected.
|
|
40
|
+
*/
|
|
41
|
+
listContainers: (options: StorageAdapterOptions) => Promise<string[]>;
|
|
42
|
+
/**
|
|
43
|
+
* Create a container used for different projects.
|
|
44
|
+
* @param containerId ID of the container
|
|
45
|
+
* @param options Common options like abortSignal.
|
|
46
|
+
* @throws if container with ID already exists.
|
|
47
|
+
*/
|
|
48
|
+
createContainer: (containerId: string, options: StorageAdapterOptions) => Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Delete an existing container.
|
|
51
|
+
* @param containerId ID of the container
|
|
52
|
+
* @param options Common options like abortSignal.
|
|
53
|
+
* @throws if container with ID does not exist.
|
|
54
|
+
*/
|
|
55
|
+
deleteContainer: (containerId: string, options: StorageAdapterOptions) => Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Check if container exists.
|
|
58
|
+
* @param containerId ID of the container
|
|
59
|
+
* @param options Common options like abortSignal.
|
|
60
|
+
* @returns if container is available of not
|
|
61
|
+
* @throws never.
|
|
62
|
+
*/
|
|
63
|
+
hasContainer: (containerId: string, options: StorageAdapterOptions) => Promise<boolean>;
|
|
64
|
+
/**
|
|
65
|
+
* Upload multiple files to the storage container
|
|
66
|
+
* @param containerId ID of the container
|
|
67
|
+
* @param files List of files with path, data and metadata
|
|
68
|
+
* @param options Common options like abortSignal
|
|
69
|
+
* @throws if the the container does not exists
|
|
70
|
+
*/
|
|
71
|
+
uploadFiles: (containerId: string, files: StoryBookerFile[], options: StorageAdapterOptions) => Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Delete multiple files by their paths or a shared prefix.
|
|
74
|
+
* @param containerId ID of the container
|
|
75
|
+
* @param filePathsOrPrefix
|
|
76
|
+
* Either a list of complete filepaths or
|
|
77
|
+
* a single string representing the shared path (prefix).
|
|
78
|
+
* @param options Common options like abortSignal
|
|
79
|
+
* @throws if the the container does not exists but NOT if file(s) does not exists
|
|
80
|
+
*/
|
|
81
|
+
deleteFiles: (containerId: string, filePathsOrPrefix: string | string[], options: StorageAdapterOptions) => Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Check if a file exists in the storage container
|
|
84
|
+
* @param containerId ID of the container
|
|
85
|
+
* @param filepath Path of the file
|
|
86
|
+
* @param options Common options like abortSignal
|
|
87
|
+
* @returns if the file exists or not
|
|
88
|
+
* @throws if the the container does not exists
|
|
89
|
+
*/
|
|
90
|
+
hasFile: (containerId: string, filepath: string, options: StorageAdapterOptions) => Promise<boolean>;
|
|
91
|
+
/**
|
|
92
|
+
* Download a single file from the storage container
|
|
93
|
+
* @param containerId ID of the container
|
|
94
|
+
* @param filepath Path of the file
|
|
95
|
+
* @param options Common options like abortSignal
|
|
96
|
+
* @returns StoryBooker file data
|
|
97
|
+
* @throws if the the container or file does not exists
|
|
98
|
+
*/
|
|
99
|
+
downloadFile: (containerId: string, filepath: string, options: StorageAdapterOptions) => Promise<Partial<StoryBookerFile>>;
|
|
100
|
+
}
|
|
101
|
+
/** Common Storage adapter options. */
|
|
102
|
+
interface StorageAdapterOptions {
|
|
103
|
+
/** A signal that can be used to cancel the request handling. */
|
|
104
|
+
abortSignal?: AbortSignal;
|
|
105
|
+
/** Logger */
|
|
106
|
+
logger: LoggerAdapter;
|
|
107
|
+
}
|
|
108
|
+
/** Shape of file/blob */
|
|
109
|
+
interface StoryBookerFile {
|
|
110
|
+
content: Blob | ReadableStream | string;
|
|
111
|
+
mimeType: string;
|
|
112
|
+
path: string;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Pre-defined Storage adapter errors
|
|
116
|
+
* that can be used across different adapters.
|
|
117
|
+
*
|
|
118
|
+
* Throws {HTTPException} with relevant status codes.
|
|
119
|
+
*/
|
|
120
|
+
declare const StorageAdapterErrors: {
|
|
121
|
+
StorageNotInitializedError: {
|
|
122
|
+
new (cause?: unknown): {
|
|
123
|
+
name: string;
|
|
124
|
+
message: string;
|
|
125
|
+
stack?: string | undefined;
|
|
126
|
+
cause?: unknown;
|
|
127
|
+
readonly res?: Response | undefined;
|
|
128
|
+
readonly status: ContentfulStatusCode;
|
|
129
|
+
getResponse(): Response;
|
|
130
|
+
};
|
|
131
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;
|
|
132
|
+
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
|
|
133
|
+
stackTraceLimit: number;
|
|
134
|
+
};
|
|
135
|
+
ContainerAlreadyExistsError: {
|
|
136
|
+
new (containerId: string, cause?: unknown): {
|
|
137
|
+
name: string;
|
|
138
|
+
message: string;
|
|
139
|
+
stack?: string | undefined;
|
|
140
|
+
cause?: unknown;
|
|
141
|
+
readonly res?: Response | undefined;
|
|
142
|
+
readonly status: ContentfulStatusCode;
|
|
143
|
+
getResponse(): Response;
|
|
144
|
+
};
|
|
145
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;
|
|
146
|
+
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
|
|
147
|
+
stackTraceLimit: number;
|
|
148
|
+
};
|
|
149
|
+
ContainerDoesNotExistError: {
|
|
150
|
+
new (containerId: string, cause?: unknown): {
|
|
151
|
+
name: string;
|
|
152
|
+
message: string;
|
|
153
|
+
stack?: string | undefined;
|
|
154
|
+
cause?: unknown;
|
|
155
|
+
readonly res?: Response | undefined;
|
|
156
|
+
readonly status: ContentfulStatusCode;
|
|
157
|
+
getResponse(): Response;
|
|
158
|
+
};
|
|
159
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;
|
|
160
|
+
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
|
|
161
|
+
stackTraceLimit: number;
|
|
162
|
+
};
|
|
163
|
+
FileDoesNotExistError: {
|
|
164
|
+
new (containerId: string, filepath: string, cause?: unknown): {
|
|
165
|
+
name: string;
|
|
166
|
+
message: string;
|
|
167
|
+
stack?: string | undefined;
|
|
168
|
+
cause?: unknown;
|
|
169
|
+
readonly res?: Response | undefined;
|
|
170
|
+
readonly status: ContentfulStatusCode;
|
|
171
|
+
getResponse(): Response;
|
|
172
|
+
};
|
|
173
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;
|
|
174
|
+
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
|
|
175
|
+
stackTraceLimit: number;
|
|
176
|
+
};
|
|
177
|
+
FileMalformedError: {
|
|
178
|
+
new (containerId: string, filepath: string, cause?: unknown): {
|
|
179
|
+
name: string;
|
|
180
|
+
message: string;
|
|
181
|
+
stack?: string | undefined;
|
|
182
|
+
cause?: unknown;
|
|
183
|
+
readonly res?: Response | undefined;
|
|
184
|
+
readonly status: ContentfulStatusCode;
|
|
185
|
+
getResponse(): Response;
|
|
186
|
+
};
|
|
187
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;
|
|
188
|
+
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
|
|
189
|
+
stackTraceLimit: number;
|
|
190
|
+
};
|
|
191
|
+
CustomError: {
|
|
192
|
+
new (status: number | undefined, message: string, cause?: unknown): {
|
|
193
|
+
name: string;
|
|
194
|
+
message: string;
|
|
195
|
+
stack?: string | undefined;
|
|
196
|
+
cause?: unknown;
|
|
197
|
+
readonly res?: Response | undefined;
|
|
198
|
+
readonly status: ContentfulStatusCode;
|
|
199
|
+
getResponse(): Response;
|
|
200
|
+
};
|
|
201
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;
|
|
202
|
+
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
|
|
203
|
+
stackTraceLimit: number;
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
//#endregion
|
|
207
|
+
export { StorageAdapter, StorageAdapterErrors, StorageAdapterOptions, StoryBookerFile };
|
|
208
|
+
//# sourceMappingURL=storage.d.mts.map
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { HTTPException } from "hono/http-exception";
|
|
2
|
+
|
|
3
|
+
//#region src/adapters/_internal/storage.ts
|
|
4
|
+
/**
|
|
5
|
+
* Pre-defined Storage adapter errors
|
|
6
|
+
* that can be used across different adapters.
|
|
7
|
+
*
|
|
8
|
+
* Throws {HTTPException} with relevant status codes.
|
|
9
|
+
*/
|
|
10
|
+
const StorageAdapterErrors = {
|
|
11
|
+
StorageNotInitializedError: class extends HTTPException {
|
|
12
|
+
constructor(cause) {
|
|
13
|
+
super(500, {
|
|
14
|
+
cause,
|
|
15
|
+
message: "Storage adapter is not initialized."
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
ContainerAlreadyExistsError: class extends HTTPException {
|
|
20
|
+
constructor(containerId, cause) {
|
|
21
|
+
super(409, {
|
|
22
|
+
cause,
|
|
23
|
+
message: `Storage container '${containerId}' already exists.`
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
ContainerDoesNotExistError: class extends HTTPException {
|
|
28
|
+
constructor(containerId, cause) {
|
|
29
|
+
super(404, {
|
|
30
|
+
cause,
|
|
31
|
+
message: `Storage container '${containerId}' does not exist.`
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
FileDoesNotExistError: class extends HTTPException {
|
|
36
|
+
constructor(containerId, filepath, cause) {
|
|
37
|
+
super(404, {
|
|
38
|
+
cause,
|
|
39
|
+
message: `Storage file '${filepath}' does not exist in container '${containerId}'.`
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
FileMalformedError: class extends HTTPException {
|
|
44
|
+
constructor(containerId, filepath, cause) {
|
|
45
|
+
super(415, {
|
|
46
|
+
cause,
|
|
47
|
+
message: `Storage file '${filepath}' is malformed in container '${containerId}'.`
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
CustomError: class extends HTTPException {
|
|
52
|
+
constructor(status, message, cause) {
|
|
53
|
+
super(status, {
|
|
54
|
+
cause,
|
|
55
|
+
message
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
//#endregion
|
|
62
|
+
export { StorageAdapterErrors };
|
|
63
|
+
//# sourceMappingURL=storage.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.mjs","names":[],"sources":["../../../src/adapters/_internal/storage.ts"],"sourcesContent":["// oxlint-disable max-classes-per-file\n\nimport { HTTPException } from \"hono/http-exception\";\nimport type { ContentfulStatusCode } from \"hono/utils/http-status\";\nimport type { StoryBookerAdapterMetadata } from \"../../utils/adapter-utils.ts\";\nimport type { LoggerAdapter } from \"./logger.ts\";\n\n/**\n * Service adapter to interact with file-storage.\n *\n * @description\n * The adapter should provide callbacks to perform operations\n * to an existing storage like upload and download files.\n *\n * - `container`: A container/group/bucket to hold files. Each project has one container.\n * - `file`: A single binary that can individually stored and retrieved.\n *\n * @throws {StorageNotInitializedError} if the Storage service is not connected.\n * @throws {ContainerAlreadyExistsError} if the container already exists.\n * @throws {ContainerDoesNotExistError} if the container does not exist.\n * @throws {FileDoesNotExistError} if the file does not exist in the container.\n * @throws {CustomError} if some other error occurs.\n */\nexport interface StorageAdapter {\n /**\n * Metadata about the adapter.\n */\n metadata: StoryBookerAdapterMetadata;\n\n /**\n * An optional method that is called on app boot-up\n * to run async setup functions.\n * @param options Common options like abortSignal.\n * @throws If the Storage service fails to initialize.\n */\n init?: (options: StorageAdapterOptions) => Promise<void>;\n\n // Containers\n\n /**\n * List all containers available in the storage.\n * @param options Common options like abortSignal.\n * @returns A list of names/IDs of the containers.\n * @throws {StorageNotInitializedError} if the Storage service is not connected.\n */\n listContainers: (options: StorageAdapterOptions) => Promise<string[]>;\n\n /**\n * Create a container used for different projects.\n * @param containerId ID of the container\n * @param options Common options like abortSignal.\n * @throws if container with ID already exists.\n */\n createContainer: (containerId: string, options: StorageAdapterOptions) => Promise<void>;\n\n /**\n * Delete an existing container.\n * @param containerId ID of the container\n * @param options Common options like abortSignal.\n * @throws if container with ID does not exist.\n */\n deleteContainer: (containerId: string, options: StorageAdapterOptions) => Promise<void>;\n\n /**\n * Check if container exists.\n * @param containerId ID of the container\n * @param options Common options like abortSignal.\n * @returns if container is available of not\n * @throws never.\n */\n hasContainer: (containerId: string, options: StorageAdapterOptions) => Promise<boolean>;\n\n // Files\n\n /**\n * Upload multiple files to the storage container\n * @param containerId ID of the container\n * @param files List of files with path, data and metadata\n * @param options Common options like abortSignal\n * @throws if the the container does not exists\n */\n uploadFiles: (\n containerId: string,\n files: StoryBookerFile[],\n options: StorageAdapterOptions,\n ) => Promise<void>;\n\n /**\n * Delete multiple files by their paths or a shared prefix.\n * @param containerId ID of the container\n * @param filePathsOrPrefix\n * Either a list of complete filepaths or\n * a single string representing the shared path (prefix).\n * @param options Common options like abortSignal\n * @throws if the the container does not exists but NOT if file(s) does not exists\n */\n deleteFiles: (\n containerId: string,\n filePathsOrPrefix: string | string[],\n options: StorageAdapterOptions,\n ) => Promise<void>;\n\n /**\n * Check if a file exists in the storage container\n * @param containerId ID of the container\n * @param filepath Path of the file\n * @param options Common options like abortSignal\n * @returns if the file exists or not\n * @throws if the the container does not exists\n */\n hasFile: (\n containerId: string,\n filepath: string,\n options: StorageAdapterOptions,\n ) => Promise<boolean>;\n\n /**\n * Download a single file from the storage container\n * @param containerId ID of the container\n * @param filepath Path of the file\n * @param options Common options like abortSignal\n * @returns StoryBooker file data\n * @throws if the the container or file does not exists\n */\n downloadFile: (\n containerId: string,\n filepath: string,\n options: StorageAdapterOptions,\n ) => Promise<Partial<StoryBookerFile>>;\n}\n\n/** Common Storage adapter options. */\nexport interface StorageAdapterOptions {\n /** A signal that can be used to cancel the request handling. */\n abortSignal?: AbortSignal;\n /** Logger */\n logger: LoggerAdapter;\n}\n\n/** Shape of file/blob */\nexport interface StoryBookerFile {\n content: Blob | ReadableStream | string;\n mimeType: string;\n path: string;\n}\n\n/**\n * Pre-defined Storage adapter errors\n * that can be used across different adapters.\n *\n * Throws {HTTPException} with relevant status codes.\n */\nexport const StorageAdapterErrors = {\n StorageNotInitializedError: class extends HTTPException {\n constructor(cause?: unknown) {\n super(500, { cause, message: \"Storage adapter is not initialized.\" });\n }\n },\n ContainerAlreadyExistsError: class extends HTTPException {\n constructor(containerId: string, cause?: unknown) {\n super(409, {\n cause,\n message: `Storage container '${containerId}' already exists.`,\n });\n }\n },\n ContainerDoesNotExistError: class extends HTTPException {\n constructor(containerId: string, cause?: unknown) {\n super(404, {\n cause,\n message: `Storage container '${containerId}' does not exist.`,\n });\n }\n },\n FileDoesNotExistError: class extends HTTPException {\n constructor(containerId: string, filepath: string, cause?: unknown) {\n super(404, {\n cause,\n message: `Storage file '${filepath}' does not exist in container '${containerId}'.`,\n });\n }\n },\n FileMalformedError: class extends HTTPException {\n constructor(containerId: string, filepath: string, cause?: unknown) {\n super(415, {\n cause,\n message: `Storage file '${filepath}' is malformed in container '${containerId}'.`,\n });\n }\n },\n CustomError: class extends HTTPException {\n constructor(status: number | undefined, message: string, cause?: unknown) {\n super(status as ContentfulStatusCode, { cause, message });\n }\n },\n // oxlint-disable-next-line no-explicit-any\n} satisfies Record<string, new (...args: any[]) => HTTPException>;\n"],"mappings":";;;;;;;;;AAwJA,MAAa,uBAAuB;CAClC,4BAA4B,cAAc,cAAc;EACtD,YAAY,OAAiB;AAC3B,SAAM,KAAK;IAAE;IAAO,SAAS;IAAuC,CAAC;;;CAGzE,6BAA6B,cAAc,cAAc;EACvD,YAAY,aAAqB,OAAiB;AAChD,SAAM,KAAK;IACT;IACA,SAAS,sBAAsB,YAAY;IAC5C,CAAC;;;CAGN,4BAA4B,cAAc,cAAc;EACtD,YAAY,aAAqB,OAAiB;AAChD,SAAM,KAAK;IACT;IACA,SAAS,sBAAsB,YAAY;IAC5C,CAAC;;;CAGN,uBAAuB,cAAc,cAAc;EACjD,YAAY,aAAqB,UAAkB,OAAiB;AAClE,SAAM,KAAK;IACT;IACA,SAAS,iBAAiB,SAAS,iCAAiC,YAAY;IACjF,CAAC;;;CAGN,oBAAoB,cAAc,cAAc;EAC9C,YAAY,aAAqB,UAAkB,OAAiB;AAClE,SAAM,KAAK;IACT;IACA,SAAS,iBAAiB,SAAS,+BAA+B,YAAY;IAC/E,CAAC;;;CAGN,aAAa,cAAc,cAAc;EACvC,YAAY,QAA4B,SAAiB,OAAiB;AACxE,SAAM,QAAgC;IAAE;IAAO;IAAS,CAAC;;;CAI9D"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { StoryBookerAdapterMetadata } from "../../utils/adapter-utils.mjs";
|
|
2
|
+
import { LoggerAdapter } from "./logger.mjs";
|
|
3
|
+
import { StoryBookerUser } from "./auth.mjs";
|
|
4
|
+
import { ParsedError } from "../../utils/error.mjs";
|
|
5
|
+
import { BuildStoryType, BuildType, BuildUploadVariant } from "../../models/builds-schema.mjs";
|
|
6
|
+
import { ProjectType } from "../../models/projects-schema.mjs";
|
|
7
|
+
import { TagType } from "../../models/tags-schema.mjs";
|
|
8
|
+
import { UrlBuilder } from "../../urls.mjs";
|
|
9
|
+
import "../types.mjs";
|
|
10
|
+
|
|
11
|
+
//#region src/adapters/_internal/ui.d.ts
|
|
12
|
+
type RenderedContent = string | Promise<string>;
|
|
13
|
+
type UIResult = Response | Promise<Response> | RenderedContent;
|
|
14
|
+
/**
|
|
15
|
+
* Adapter for creating UI for StoryBooker service.
|
|
16
|
+
*
|
|
17
|
+
* The render methods are called asynchronously and can return promise of HTML.
|
|
18
|
+
*/
|
|
19
|
+
interface UIAdapter {
|
|
20
|
+
/**
|
|
21
|
+
* Metadata about the adapter.
|
|
22
|
+
*/
|
|
23
|
+
metadata: StoryBookerAdapterMetadata;
|
|
24
|
+
/**
|
|
25
|
+
* A special handler that is invoked when no existing StoryBooker route is matched.
|
|
26
|
+
*
|
|
27
|
+
* This can be used to serve special routes and/or static files from disk.
|
|
28
|
+
*/
|
|
29
|
+
handleUnhandledRoute?(filepath: string, options: UIAdapterOptions): Response | Promise<Response>;
|
|
30
|
+
renderHomePage?(props: {
|
|
31
|
+
projects: ProjectType[];
|
|
32
|
+
}, options: UIAdapterOptions): UIResult;
|
|
33
|
+
renderErrorPage?(props: ParsedError, options: UIAdapterOptions): UIResult;
|
|
34
|
+
renderAccountsPage?(props: {
|
|
35
|
+
children: string | undefined;
|
|
36
|
+
}, options: UIAdapterOptions): UIResult;
|
|
37
|
+
renderProjectsListPage?(props: {
|
|
38
|
+
projects: ProjectType[];
|
|
39
|
+
}, options: UIAdapterOptions): UIResult;
|
|
40
|
+
renderProjectDetailsPage?(props: {
|
|
41
|
+
project: ProjectType;
|
|
42
|
+
recentBuilds: BuildType[];
|
|
43
|
+
recentTags: TagType[];
|
|
44
|
+
}, options: UIAdapterOptions): UIResult;
|
|
45
|
+
renderProjectCreatePage?(props: unknown, options: UIAdapterOptions): UIResult;
|
|
46
|
+
renderProjectUpdatePage?(props: {
|
|
47
|
+
project: ProjectType;
|
|
48
|
+
}, options: UIAdapterOptions): UIResult;
|
|
49
|
+
renderTagsListPage?(props: {
|
|
50
|
+
tags: TagType[];
|
|
51
|
+
project: ProjectType;
|
|
52
|
+
defaultType?: string | null;
|
|
53
|
+
}, options: UIAdapterOptions): UIResult;
|
|
54
|
+
renderTagDetailsPage?(props: {
|
|
55
|
+
tag: TagType;
|
|
56
|
+
project: ProjectType;
|
|
57
|
+
builds: BuildType[];
|
|
58
|
+
}, options: UIAdapterOptions): UIResult;
|
|
59
|
+
renderTagCreatePage?(props: {
|
|
60
|
+
project: ProjectType;
|
|
61
|
+
}, options: UIAdapterOptions): UIResult;
|
|
62
|
+
renderTagUpdatePage?(props: {
|
|
63
|
+
tag: TagType;
|
|
64
|
+
project: ProjectType;
|
|
65
|
+
}, options: UIAdapterOptions): UIResult;
|
|
66
|
+
renderBuildsListPage?(props: {
|
|
67
|
+
builds: BuildType[];
|
|
68
|
+
project: ProjectType;
|
|
69
|
+
}, options: UIAdapterOptions): UIResult;
|
|
70
|
+
renderBuildDetailsPage?(props: {
|
|
71
|
+
build: BuildType;
|
|
72
|
+
project: ProjectType;
|
|
73
|
+
stories: BuildStoryType[] | null;
|
|
74
|
+
}, options: UIAdapterOptions): UIResult;
|
|
75
|
+
renderBuildCreatePage?(props: {
|
|
76
|
+
project: ProjectType;
|
|
77
|
+
tagId?: string;
|
|
78
|
+
}, options: UIAdapterOptions): UIResult;
|
|
79
|
+
renderBuildUploadPage?(props: {
|
|
80
|
+
build: BuildType;
|
|
81
|
+
project: ProjectType;
|
|
82
|
+
uploadVariant?: BuildUploadVariant;
|
|
83
|
+
}, options: UIAdapterOptions): UIResult;
|
|
84
|
+
}
|
|
85
|
+
/** Common UI adapter options. */
|
|
86
|
+
interface UIAdapterOptions {
|
|
87
|
+
isAuthEnabled: boolean;
|
|
88
|
+
/** Logger */
|
|
89
|
+
logger: LoggerAdapter;
|
|
90
|
+
/** Logged-in user */
|
|
91
|
+
user: StoryBookerUser | null | undefined;
|
|
92
|
+
/** Current url */
|
|
93
|
+
url: string;
|
|
94
|
+
/** Current locale */
|
|
95
|
+
locale: string;
|
|
96
|
+
/** URL builder */
|
|
97
|
+
urlBuilder: UrlBuilder;
|
|
98
|
+
/** Metadata about all adapters */
|
|
99
|
+
adaptersMetadata: {
|
|
100
|
+
auth?: StoryBookerAdapterMetadata;
|
|
101
|
+
database?: StoryBookerAdapterMetadata;
|
|
102
|
+
logger?: StoryBookerAdapterMetadata;
|
|
103
|
+
storage?: StoryBookerAdapterMetadata;
|
|
104
|
+
ui?: StoryBookerAdapterMetadata;
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
//#endregion
|
|
108
|
+
export { RenderedContent, UIAdapter, UIAdapterOptions, UIResult };
|
|
109
|
+
//# sourceMappingURL=ui.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { StoryBookerAdapterMetadata } from "../utils/adapter-utils.mjs";
|
|
2
|
+
import { LoggerAdapter, createConsoleLoggerAdapter } from "./adapter/logger.mjs";
|
|
3
|
+
import { AuthAdapter, AuthAdapterAuthorise, AuthAdapterOptions, StoryBookerPermission, StoryBookerPermissionAction, StoryBookerPermissionKey, StoryBookerPermissionResource, StoryBookerPermissionWithKey, StoryBookerPermissionsAllEnabled, StoryBookerPermissionsList, StoryBookerUser } from "./adapter/auth.mjs";
|
|
4
|
+
import { DatabaseAdapter, DatabaseAdapterErrors, DatabaseAdapterOptions, DatabaseDocumentListOptions, StoryBookerDatabaseDocument } from "./adapter/database.mjs";
|
|
5
|
+
import { QueueAdapter, QueueAdapterOptions, QueueMessageReceiveOptions, StoryBookerQueueMessage } from "../adapters/_internal/queue.mjs";
|
|
6
|
+
import { StorageAdapter, StorageAdapterErrors, StorageAdapterOptions, StoryBookerFile } from "./adapter/storage.mjs";
|
|
7
|
+
import { RenderedContent, UIAdapter, UIAdapterOptions, UIResult } from "./adapter/ui.mjs";
|
|
8
|
+
export { AuthAdapter, AuthAdapterAuthorise, AuthAdapterOptions, DatabaseAdapter, DatabaseAdapterErrors, DatabaseAdapterOptions, DatabaseDocumentListOptions, LoggerAdapter, QueueAdapter, QueueAdapterOptions, QueueMessageReceiveOptions, RenderedContent, StorageAdapter, StorageAdapterErrors, StorageAdapterOptions, type StoryBookerAdapterMetadata, StoryBookerDatabaseDocument, StoryBookerFile, StoryBookerPermission, StoryBookerPermissionAction, StoryBookerPermissionKey, StoryBookerPermissionResource, StoryBookerPermissionWithKey, StoryBookerPermissionsAllEnabled, StoryBookerPermissionsList, StoryBookerQueueMessage, StoryBookerUser, UIAdapter, UIAdapterOptions, UIResult, createConsoleLoggerAdapter };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { StoryBookerPermissionsAllEnabled, StoryBookerPermissionsList } from "./adapter/auth.mjs";
|
|
2
|
+
import { DatabaseAdapterErrors } from "./adapter/database.mjs";
|
|
3
|
+
import { createConsoleLoggerAdapter } from "./adapter/logger.mjs";
|
|
4
|
+
import { StorageAdapterErrors } from "./adapter/storage.mjs";
|
|
5
|
+
|
|
6
|
+
export { DatabaseAdapterErrors, StorageAdapterErrors, StoryBookerPermissionsAllEnabled, StoryBookerPermissionsList, createConsoleLoggerAdapter };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//#region src/utils/constants.d.ts
|
|
2
|
+
declare const SERVICE_NAME = "StoryBooker";
|
|
3
|
+
declare const SERVICE_SHORT_NAME = "SBR";
|
|
4
|
+
declare const CACHE_CONTROL_PUBLIC_YEAR = "public, max-age=31536000, immutable";
|
|
5
|
+
declare const DEFAULT_PURGE_AFTER_DAYS = 30;
|
|
6
|
+
declare const DEFAULT_GITHUB_BRANCH = "main";
|
|
7
|
+
declare const ONE_DAY_IN_MS: number;
|
|
8
|
+
declare const DEFAULT_LOCALE = "en";
|
|
9
|
+
declare const QUERY_PARAMS: {
|
|
10
|
+
readonly tagId: "tagId";
|
|
11
|
+
readonly uploadVariant: "variant";
|
|
12
|
+
readonly redirect: "redirect";
|
|
13
|
+
};
|
|
14
|
+
declare const PATTERNS: {
|
|
15
|
+
projectId: {
|
|
16
|
+
message: string;
|
|
17
|
+
pattern: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
declare const TagTypes: readonly ["branch", "pr", "jira"];
|
|
21
|
+
declare const buildUploadVariants: readonly ["storybook", "testReport", "coverage", "screenshots"];
|
|
22
|
+
//#endregion
|
|
23
|
+
export { CACHE_CONTROL_PUBLIC_YEAR, DEFAULT_GITHUB_BRANCH, DEFAULT_LOCALE, DEFAULT_PURGE_AFTER_DAYS, ONE_DAY_IN_MS, PATTERNS, QUERY_PARAMS, SERVICE_NAME, SERVICE_SHORT_NAME, TagTypes, buildUploadVariants };
|
|
24
|
+
//# sourceMappingURL=constants.d.mts.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//#region src/utils/constants.ts
|
|
2
|
+
const SERVICE_NAME = "StoryBooker";
|
|
3
|
+
const SERVICE_SHORT_NAME = "SBR";
|
|
4
|
+
const CACHE_CONTROL_PUBLIC_YEAR = "public, max-age=31536000, immutable";
|
|
5
|
+
const DEFAULT_PURGE_AFTER_DAYS = 30;
|
|
6
|
+
const DEFAULT_GITHUB_BRANCH = "main";
|
|
7
|
+
const ONE_DAY_IN_MS = 1440 * 60 * 1e3;
|
|
8
|
+
const DEFAULT_LOCALE = "en";
|
|
9
|
+
const QUERY_PARAMS = {
|
|
10
|
+
tagId: "tagId",
|
|
11
|
+
uploadVariant: "variant",
|
|
12
|
+
redirect: "redirect"
|
|
13
|
+
};
|
|
14
|
+
const PATTERNS = { projectId: {
|
|
15
|
+
message: "Should contain only lowercase alphabets, numbers and hyphen.",
|
|
16
|
+
pattern: "^[a-z0-9][a-z0-9-]{0,60}$"
|
|
17
|
+
} };
|
|
18
|
+
const TagTypes = [
|
|
19
|
+
"branch",
|
|
20
|
+
"pr",
|
|
21
|
+
"jira"
|
|
22
|
+
];
|
|
23
|
+
const buildUploadVariants = [
|
|
24
|
+
"storybook",
|
|
25
|
+
"testReport",
|
|
26
|
+
"coverage",
|
|
27
|
+
"screenshots"
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
export { CACHE_CONTROL_PUBLIC_YEAR, DEFAULT_GITHUB_BRANCH, DEFAULT_LOCALE, DEFAULT_PURGE_AFTER_DAYS, ONE_DAY_IN_MS, PATTERNS, QUERY_PARAMS, SERVICE_NAME, SERVICE_SHORT_NAME, TagTypes, buildUploadVariants };
|
|
32
|
+
//# sourceMappingURL=constants.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.mjs","names":["ONE_DAY_IN_MS: number"],"sources":["../../src/utils/constants.ts"],"sourcesContent":["export const SERVICE_NAME = \"StoryBooker\";\nexport const SERVICE_SHORT_NAME = \"SBR\";\nexport const CACHE_CONTROL_PUBLIC_YEAR = \"public, max-age=31536000, immutable\";\n\nexport const DEFAULT_PURGE_AFTER_DAYS = 30;\nexport const DEFAULT_GITHUB_BRANCH = \"main\";\nexport const ONE_DAY_IN_MS: number = 24 * 60 * 60 * 1000;\nexport const DEFAULT_LOCALE = \"en\";\n\nexport const QUERY_PARAMS = {\n tagId: \"tagId\",\n uploadVariant: \"variant\",\n redirect: \"redirect\",\n} as const;\n\nexport const PATTERNS = {\n projectId: {\n message: \"Should contain only lowercase alphabets, numbers and hyphen.\",\n pattern: \"^[a-z0-9][a-z0-9-]{0,60}$\",\n },\n} satisfies Record<\n string,\n {\n pattern: string | RegExp;\n patternGlobal?: string | RegExp;\n message?: string;\n }\n>;\n\nexport const TagTypes = [\"branch\", \"pr\", \"jira\"] as const;\nexport const buildUploadVariants = [\"storybook\", \"testReport\", \"coverage\", \"screenshots\"] as const;\n"],"mappings":";AAAA,MAAa,eAAe;AAC5B,MAAa,qBAAqB;AAClC,MAAa,4BAA4B;AAEzC,MAAa,2BAA2B;AACxC,MAAa,wBAAwB;AACrC,MAAaA,gBAAwB,OAAU,KAAK;AACpD,MAAa,iBAAiB;AAE9B,MAAa,eAAe;CAC1B,OAAO;CACP,eAAe;CACf,UAAU;CACX;AAED,MAAa,WAAW,EACtB,WAAW;CACT,SAAS;CACT,SAAS;CACV,EACF;AASD,MAAa,WAAW;CAAC;CAAU;CAAM;CAAO;AAChD,MAAa,sBAAsB;CAAC;CAAa;CAAc;CAAY;CAAc"}
|