@supernova-studio/model 1.0.0 → 1.0.1
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/dist/index.d.mts +26740 -18977
- package/dist/index.d.ts +26740 -18977
- package/dist/index.js +275 -47
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2201 -1973
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -4
- package/src/asset-delete-schedule/asset-delete-schedule.ts +0 -20
- package/src/asset-delete-schedule/index.ts +0 -1
- package/src/auth/index.ts +0 -1
- package/src/auth/plugin-oauth-request.ts +0 -14
- package/src/billing/card.ts +0 -12
- package/src/billing/checkoutSession.ts +0 -16
- package/src/billing/customer.ts +0 -29
- package/src/billing/features.ts +0 -48
- package/src/billing/index.ts +0 -9
- package/src/billing/invoice.ts +0 -34
- package/src/billing/portalSession.ts +0 -19
- package/src/billing/price.ts +0 -24
- package/src/billing/product.ts +0 -5
- package/src/billing/subscription.ts +0 -65
- package/src/common/entity.ts +0 -9
- package/src/common/index.ts +0 -2
- package/src/common/object-meta.ts +0 -8
- package/src/custom-domains/custom-domains.ts +0 -24
- package/src/custom-domains/index.ts +0 -1
- package/src/data-dumps/code-integration-dump.ts +0 -19
- package/src/data-dumps/design-system-dump.ts +0 -16
- package/src/data-dumps/design-system-version-dump.ts +0 -45
- package/src/data-dumps/index.ts +0 -6
- package/src/data-dumps/published-docs-dump.ts +0 -10
- package/src/data-dumps/user-data-dump.ts +0 -10
- package/src/data-dumps/workspace-dump.ts +0 -14
- package/src/docs-server/index.ts +0 -1
- package/src/docs-server/session.ts +0 -39
- package/src/dsm/assets/asset-dynamo-record.ts +0 -10
- package/src/dsm/assets/asset-reference.ts +0 -18
- package/src/dsm/assets/asset-value.ts +0 -3
- package/src/dsm/assets/asset.ts +0 -60
- package/src/dsm/assets/index.ts +0 -4
- package/src/dsm/brand.ts +0 -13
- package/src/dsm/collection.ts +0 -51
- package/src/dsm/components/asset-rendering.ts +0 -22
- package/src/dsm/components/index.ts +0 -1
- package/src/dsm/data-sources/data-source.ts +0 -167
- package/src/dsm/data-sources/import-job.ts +0 -30
- package/src/dsm/data-sources/import-summary.ts +0 -70
- package/src/dsm/data-sources/index.ts +0 -3
- package/src/dsm/design-system.ts +0 -47
- package/src/dsm/documentation/approvals/approval-state.ts +0 -4
- package/src/dsm/documentation/approvals/approval.ts +0 -18
- package/src/dsm/documentation/approvals/index.ts +0 -2
- package/src/dsm/documentation/block-definitions/aux.ts +0 -10
- package/src/dsm/documentation/block-definitions/definition.ts +0 -76
- package/src/dsm/documentation/block-definitions/index.ts +0 -4
- package/src/dsm/documentation/block-definitions/item.ts +0 -233
- package/src/dsm/documentation/block-definitions/variant.ts +0 -49
- package/src/dsm/documentation/group.ts +0 -19
- package/src/dsm/documentation/index.ts +0 -10
- package/src/dsm/documentation/link-preview.ts +0 -10
- package/src/dsm/documentation/page-anchor.ts +0 -9
- package/src/dsm/documentation/page-content-backup.ts +0 -13
- package/src/dsm/documentation/page-content.ts +0 -32
- package/src/dsm/documentation/page.ts +0 -18
- package/src/dsm/documentation/settings.ts +0 -18
- package/src/dsm/documentation/thread.ts +0 -35
- package/src/dsm/element-snapshots/base.ts +0 -34
- package/src/dsm/element-snapshots/documentation-page-snapshot.ts +0 -29
- package/src/dsm/element-snapshots/group-snapshot.ts +0 -27
- package/src/dsm/element-snapshots/index.ts +0 -3
- package/src/dsm/elements/base.ts +0 -49
- package/src/dsm/elements/component-properties.ts +0 -63
- package/src/dsm/elements/data/base.ts +0 -18
- package/src/dsm/elements/data/blur.ts +0 -16
- package/src/dsm/elements/data/border-radius.ts +0 -16
- package/src/dsm/elements/data/border-width.ts +0 -16
- package/src/dsm/elements/data/border.ts +0 -21
- package/src/dsm/elements/data/color.ts +0 -13
- package/src/dsm/elements/data/component.ts +0 -30
- package/src/dsm/elements/data/dimension.ts +0 -15
- package/src/dsm/elements/data/documentation-block-v1.ts +0 -498
- package/src/dsm/elements/data/documentation-block-v2.ts +0 -429
- package/src/dsm/elements/data/documentation-page-v1.ts +0 -9
- package/src/dsm/elements/data/documentation-page-v2.ts +0 -7
- package/src/dsm/elements/data/documentation-section-v2.ts +0 -47
- package/src/dsm/elements/data/documentation-v1.ts +0 -16
- package/src/dsm/elements/data/documentation-v2.ts +0 -18
- package/src/dsm/elements/data/duration.ts +0 -16
- package/src/dsm/elements/data/figma-file-structure.ts +0 -65
- package/src/dsm/elements/data/figma-node-reference.ts +0 -27
- package/src/dsm/elements/data/font-family.ts +0 -8
- package/src/dsm/elements/data/font-size.ts +0 -16
- package/src/dsm/elements/data/font-weight.ts +0 -8
- package/src/dsm/elements/data/font.ts +0 -9
- package/src/dsm/elements/data/gradient.ts +0 -32
- package/src/dsm/elements/data/group.ts +0 -20
- package/src/dsm/elements/data/index.ts +0 -43
- package/src/dsm/elements/data/item-header-v1.ts +0 -35
- package/src/dsm/elements/data/item-header-v2.ts +0 -34
- package/src/dsm/elements/data/item-header.ts +0 -14
- package/src/dsm/elements/data/letter-spacing.ts +0 -16
- package/src/dsm/elements/data/line-height.ts +0 -16
- package/src/dsm/elements/data/opacity.ts +0 -13
- package/src/dsm/elements/data/paragraph-indent.ts +0 -16
- package/src/dsm/elements/data/paragraph-spacing.ts +0 -16
- package/src/dsm/elements/data/product-copy.ts +0 -8
- package/src/dsm/elements/data/safe-id.ts +0 -13
- package/src/dsm/elements/data/shadow.ts +0 -23
- package/src/dsm/elements/data/size.ts +0 -16
- package/src/dsm/elements/data/space.ts +0 -16
- package/src/dsm/elements/data/string.ts +0 -8
- package/src/dsm/elements/data/text-case.ts +0 -10
- package/src/dsm/elements/data/text-decoration.ts +0 -10
- package/src/dsm/elements/data/typography.ts +0 -28
- package/src/dsm/elements/data/visibility.ts +0 -10
- package/src/dsm/elements/data/z-index.ts +0 -16
- package/src/dsm/elements/documentation-page-v1.ts +0 -34
- package/src/dsm/elements/documentation-page-v2.ts +0 -21
- package/src/dsm/elements/figma-component.ts +0 -67
- package/src/dsm/elements/figma-file-structures.ts +0 -40
- package/src/dsm/elements/figma-node-reference.ts +0 -25
- package/src/dsm/elements/group.ts +0 -40
- package/src/dsm/elements/index.ts +0 -15
- package/src/dsm/elements/page-block-v2.ts +0 -25
- package/src/dsm/elements/primitives/index.ts +0 -2
- package/src/dsm/elements/primitives/point.ts +0 -8
- package/src/dsm/elements/primitives/size.ts +0 -28
- package/src/dsm/elements/raw-element.ts +0 -164
- package/src/dsm/elements/theme.ts +0 -76
- package/src/dsm/elements/tokens.ts +0 -311
- package/src/dsm/elements/utils.ts +0 -114
- package/src/dsm/exporter-property-values-collection.ts +0 -31
- package/src/dsm/import/asset.ts +0 -6
- package/src/dsm/import/base.ts +0 -24
- package/src/dsm/import/collection.ts +0 -16
- package/src/dsm/import/component.ts +0 -40
- package/src/dsm/import/data-source.ts +0 -9
- package/src/dsm/import/figma-frames.ts +0 -74
- package/src/dsm/import/image.ts +0 -87
- package/src/dsm/import/index.ts +0 -12
- package/src/dsm/import/origin.ts +0 -5
- package/src/dsm/import/support/figma-files.ts +0 -19
- package/src/dsm/import/support/import-context.ts +0 -94
- package/src/dsm/import/support/import-model-collections.ts +0 -50
- package/src/dsm/import/support/index.ts +0 -3
- package/src/dsm/import/theme.ts +0 -76
- package/src/dsm/import/tokens.ts +0 -50
- package/src/dsm/import/warning.ts +0 -38
- package/src/dsm/index.ts +0 -19
- package/src/dsm/membership/additions.ts +0 -13
- package/src/dsm/membership/design-system-membership.ts +0 -92
- package/src/dsm/membership/ds-role.ts +0 -28
- package/src/dsm/membership/index.ts +0 -4
- package/src/dsm/membership/invitations.ts +0 -21
- package/src/dsm/properties/index.ts +0 -3
- package/src/dsm/properties/property-definition.ts +0 -57
- package/src/dsm/properties/property-reference.ts +0 -5
- package/src/dsm/properties/property-value.ts +0 -29
- package/src/dsm/published-doc-page-visits.ts +0 -15
- package/src/dsm/published-doc-page.ts +0 -37
- package/src/dsm/published-doc.ts +0 -32
- package/src/dsm/reference.ts +0 -9
- package/src/dsm/version.ts +0 -41
- package/src/dsm/views/column.ts +0 -58
- package/src/dsm/views/index.ts +0 -2
- package/src/dsm/views/view.ts +0 -19
- package/src/emails/design-system-invite.ts +0 -31
- package/src/emails/index.ts +0 -2
- package/src/emails/workspace-invite.ts +0 -29
- package/src/events/base.ts +0 -7
- package/src/events/data-source-imported.ts +0 -9
- package/src/events/index.ts +0 -3
- package/src/events/version-released.ts +0 -10
- package/src/export/export-destinations.ts +0 -127
- package/src/export/export-jobs.ts +0 -122
- package/src/export/export-runner/export-context.ts +0 -34
- package/src/export/export-runner/exporter-payload.ts +0 -10
- package/src/export/export-runner/index.ts +0 -2
- package/src/export/exporter-workspace-membership-role.ts +0 -4
- package/src/export/exporter-workspace-membership.ts +0 -14
- package/src/export/exporter.ts +0 -55
- package/src/export/git-providers.ts +0 -11
- package/src/export/index.ts +0 -9
- package/src/export/pipeline.ts +0 -34
- package/src/export/pulsar.ts +0 -71
- package/src/feature-flags/feature-flags.ts +0 -21
- package/src/feature-flags/index.ts +0 -1
- package/src/helpers/db.ts +0 -82
- package/src/helpers/index.ts +0 -2
- package/src/helpers/nullish-to-optional.ts +0 -9
- package/src/index.ts +0 -20
- package/src/integrations/external-oauth-request.ts +0 -12
- package/src/integrations/git.ts +0 -49
- package/src/integrations/index.ts +0 -6
- package/src/integrations/integration.ts +0 -143
- package/src/integrations/oauth-providers.ts +0 -13
- package/src/integrations/oauth-token.ts +0 -16
- package/src/integrations/workspace-oauth-requests.ts +0 -12
- package/src/liveblocks/index.ts +0 -1
- package/src/liveblocks/rooms/design-system-version-room.ts +0 -62
- package/src/liveblocks/rooms/documentation-page-room.ts +0 -65
- package/src/liveblocks/rooms/index.ts +0 -4
- package/src/liveblocks/rooms/room-type.ts +0 -12
- package/src/liveblocks/rooms/workspace-room.ts +0 -16
- package/src/npm/index.ts +0 -2
- package/src/npm/npm-package.ts +0 -30
- package/src/npm/npm-proxy-token-payload.ts +0 -7
- package/src/tokens/index.ts +0 -1
- package/src/tokens/personal-access-token.ts +0 -25
- package/src/users/index.ts +0 -9
- package/src/users/linked-integrations.ts +0 -36
- package/src/users/user-analytics-cleanup-schedule.ts +0 -15
- package/src/users/user-identity.ts +0 -8
- package/src/users/user-minified.ts +0 -10
- package/src/users/user-notification-settings.ts +0 -18
- package/src/users/user-profile.ts +0 -41
- package/src/users/user-test.ts +0 -8
- package/src/users/user-with-pat.ts +0 -7
- package/src/users/user.ts +0 -21
- package/src/utils/common.ts +0 -172
- package/src/utils/content-loader-instruction.ts +0 -31
- package/src/utils/errors.ts +0 -120
- package/src/utils/index.ts +0 -6
- package/src/utils/naming.ts +0 -73
- package/src/utils/slugify.ts +0 -636
- package/src/utils/validation.ts +0 -4
- package/src/workspace/index.ts +0 -10
- package/src/workspace/npm-registry-settings.ts +0 -45
- package/src/workspace/sso-provider.ts +0 -13
- package/src/workspace/user-invite.ts +0 -18
- package/src/workspace/workspace-configuration.ts +0 -14
- package/src/workspace/workspace-context.ts +0 -13
- package/src/workspace/workspace-create.ts +0 -25
- package/src/workspace/workspace-invitations.ts +0 -22
- package/src/workspace/workspace-membership.ts +0 -31
- package/src/workspace/workspace-role.ts +0 -6
- package/src/workspace/workspace.ts +0 -62
package/src/users/user.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { UserLinkedIntegrations } from "./linked-integrations";
|
|
3
|
-
import { UserProfile } from "./user-profile";
|
|
4
|
-
|
|
5
|
-
export const UserSource = z.enum(["SignUp", "Invite", "SSO"]);
|
|
6
|
-
|
|
7
|
-
export const User = z.object({
|
|
8
|
-
id: z.string(),
|
|
9
|
-
email: z.string(),
|
|
10
|
-
emailVerified: z.boolean(),
|
|
11
|
-
createdAt: z.coerce.date(),
|
|
12
|
-
trialExpiresAt: z.coerce.date().optional(),
|
|
13
|
-
profile: UserProfile,
|
|
14
|
-
linkedIntegrations: UserLinkedIntegrations.optional(),
|
|
15
|
-
loggedOutAt: z.coerce.date().optional(),
|
|
16
|
-
isProtected: z.boolean(),
|
|
17
|
-
source: UserSource.optional(),
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
export type UserSource = z.infer<typeof UserSource>;
|
|
21
|
-
export type User = z.infer<typeof User>;
|
package/src/utils/common.ts
DELETED
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import { SupernovaException } from "./errors";
|
|
2
|
-
|
|
3
|
-
export type OmitStrict<T, K extends keyof T> = T extends any ? Pick<T, Exclude<keyof T, K>> : never;
|
|
4
|
-
|
|
5
|
-
export type Nullish<T> = T | null | undefined;
|
|
6
|
-
|
|
7
|
-
export type ExplicitPartial<T> = { [P in keyof T]: T[P] | undefined };
|
|
8
|
-
|
|
9
|
-
// Magic as far as I'm concerned.
|
|
10
|
-
// Taken from https://stackoverflow.com/a/50375286/3229534
|
|
11
|
-
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
12
|
-
|
|
13
|
-
// This utility lets T be indexed by any key
|
|
14
|
-
type Indexify<T> = T & { [str: string]: undefined };
|
|
15
|
-
|
|
16
|
-
// To make a type where all values are undefined, so that in AllUnionKeys<T>
|
|
17
|
-
// TS doesn't remove the keys whose values are incompatible, e.g. string & number
|
|
18
|
-
type UndefinedVals<T> = { [K in keyof T]: undefined };
|
|
19
|
-
|
|
20
|
-
// This returns a union of all keys present across all members of the union T
|
|
21
|
-
type AllUnionKeys<T> = keyof UnionToIntersection<UndefinedVals<T>>;
|
|
22
|
-
|
|
23
|
-
// Where the (rest of the) magic happens ✨
|
|
24
|
-
export type AllFields<T> = { [K in AllUnionKeys<T> & string]: Indexify<T>[K] };
|
|
25
|
-
|
|
26
|
-
export type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
|
|
27
|
-
|
|
28
|
-
export type Defined<T> = T extends null | undefined ? never : T;
|
|
29
|
-
|
|
30
|
-
// Makes specific properties in the type required
|
|
31
|
-
export type WithRequired<T, K extends keyof T> = T & { [P in K]-?: T[P] };
|
|
32
|
-
|
|
33
|
-
export function forceUnwrapNullish<T>(value: Nullish<T>): T {
|
|
34
|
-
if (value === null) throw new Error("Illegal null");
|
|
35
|
-
if (value === undefined) throw new Error("Illegal undefined");
|
|
36
|
-
return value;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export function trimLeadingSlash(string: string): string {
|
|
40
|
-
return string.startsWith("/") ? string.substring(1) : string;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export function trimTrailingSlash(string: string): string {
|
|
44
|
-
return string.endsWith("/") ? string.substring(0, string.length - 1) : string;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export function tryParseUrl(url: string): URL | null {
|
|
48
|
-
try {
|
|
49
|
-
return parseUrl(url);
|
|
50
|
-
} catch (e) {
|
|
51
|
-
console.error(`Error parsing URL ${url}`);
|
|
52
|
-
console.error(e);
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export function parseUrl(url: string): URL {
|
|
58
|
-
return new URL(url.startsWith("https://") || url.startsWith("http://") ? url : `https://${url}`);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export function mapByUnique<V, K>(items: Iterable<V>, keyFn: (item: V) => K): Map<K, V> {
|
|
62
|
-
const result = new Map<K, V>();
|
|
63
|
-
for (const item of items) {
|
|
64
|
-
result.set(keyFn(item), item);
|
|
65
|
-
}
|
|
66
|
-
return result;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export function groupBy<V, K>(items: V[], keyFn: (item: V) => K): Map<K, V[]> {
|
|
70
|
-
const result = new Map<K, V[]>();
|
|
71
|
-
|
|
72
|
-
for (const item of items) {
|
|
73
|
-
const key = keyFn(item);
|
|
74
|
-
const array = result.get(key);
|
|
75
|
-
if (array) {
|
|
76
|
-
array.push(item);
|
|
77
|
-
} else {
|
|
78
|
-
result.set(key, [item]);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return result;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export function filterNonNullish<T>(items: Nullish<T>[]): T[] {
|
|
86
|
-
return items.filter(Boolean) as T[];
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export function nonNullishFilter<T>(item: Nullish<T>): item is T {
|
|
90
|
-
return !!item;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export function nonNullFilter<T>(item: T | null): item is T {
|
|
94
|
-
return item !== null;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export type ArrayElementType<T extends Default[], Default = any> = T extends (infer U)[] ? U : Default;
|
|
98
|
-
|
|
99
|
-
export function buildConstantEnum<Inferred extends ArrayElementType<Passed>[], Passed extends string[]>(
|
|
100
|
-
values: Inferred
|
|
101
|
-
): { [key in Inferred[number]]: key } {
|
|
102
|
-
const constMap = values.reduce((acc, code) => ({ ...acc, [code]: code }), {});
|
|
103
|
-
|
|
104
|
-
return constMap as { [key in Inferred[number]]: key };
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export async function promiseWithTimeout<T>(
|
|
108
|
-
timeoutMs: number,
|
|
109
|
-
promise: () => Promise<T>,
|
|
110
|
-
onTimeout?: () => Error
|
|
111
|
-
): Promise<T> {
|
|
112
|
-
let timeoutHandle: NodeJS.Timeout | undefined;
|
|
113
|
-
const timeoutPromise = new Promise<never>((_, reject) => {
|
|
114
|
-
timeoutHandle = setTimeout(() => reject(onTimeout?.() ?? SupernovaException.timeout()), timeoutMs);
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
const result = await Promise.race([promise(), timeoutPromise]);
|
|
118
|
-
|
|
119
|
-
clearTimeout(timeoutHandle);
|
|
120
|
-
return result;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
export async function sleep(ms: number): Promise<void> {
|
|
124
|
-
return new Promise(resolve => setTimeout(resolve, ms));
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
export function uniqueBy<K, V>(items: V[], prop: (v: V) => K): V[] {
|
|
128
|
-
return Array.from(mapByUnique(items, prop).values());
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
export function areShallowObjectsEqual<T extends object>(lhs: T | undefined, rhs: T | undefined) {
|
|
132
|
-
if ((lhs === undefined) !== (rhs === undefined)) return false;
|
|
133
|
-
if (lhs === undefined || rhs === undefined) return true;
|
|
134
|
-
|
|
135
|
-
if ((lhs === null) !== (rhs === null)) return false;
|
|
136
|
-
if (lhs === null || rhs === null) return true;
|
|
137
|
-
|
|
138
|
-
for (const key in lhs) {
|
|
139
|
-
if (!(key in rhs) || lhs[key] !== rhs[key]) {
|
|
140
|
-
return false;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
for (const key in rhs) {
|
|
145
|
-
if (!(key in lhs)) {
|
|
146
|
-
return false;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
return true;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
export function isNotNullish<T>(value: T | null | undefined): value is T {
|
|
154
|
-
return !isNullish(value);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
export function isNullish<T>(value: T | null | undefined): value is null | undefined {
|
|
158
|
-
return value === null || value === undefined;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
export function chunkedArray<V>(array: V[], chunkSize: number): V[][] {
|
|
162
|
-
const result: V[][] = [];
|
|
163
|
-
for (let i = 0; i < array.length; i += chunkSize) {
|
|
164
|
-
result.push(array.slice(i, i + chunkSize));
|
|
165
|
-
}
|
|
166
|
-
return result;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
export type Pagination = {
|
|
170
|
-
skip?: number;
|
|
171
|
-
take?: number;
|
|
172
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
|
|
3
|
-
export const ContentLoadInstruction = z.object({
|
|
4
|
-
from: z.string(),
|
|
5
|
-
to: z.string(),
|
|
6
|
-
authorizationHeaderKvsId: z.string().optional(),
|
|
7
|
-
timeout: z.number().optional(),
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
export type ContentLoadInstruction = z.infer<typeof ContentLoadInstruction>;
|
|
11
|
-
|
|
12
|
-
export const ContentLoaderPayload = z
|
|
13
|
-
.object({
|
|
14
|
-
type: z.literal("Single"),
|
|
15
|
-
instruction: ContentLoadInstruction,
|
|
16
|
-
})
|
|
17
|
-
.or(
|
|
18
|
-
z.object({
|
|
19
|
-
type: z.literal("Multiple"),
|
|
20
|
-
loadingChunkSize: z.number().optional(),
|
|
21
|
-
instructions: z.array(ContentLoadInstruction),
|
|
22
|
-
})
|
|
23
|
-
)
|
|
24
|
-
.or(
|
|
25
|
-
z.object({
|
|
26
|
-
type: z.literal("S3"),
|
|
27
|
-
location: z.string(),
|
|
28
|
-
})
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
export type ContentLoaderPayload = z.infer<typeof ContentLoaderPayload>;
|
package/src/utils/errors.ts
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
export type SupernovaExceptionType =
|
|
2
|
-
| "AccessDenied"
|
|
3
|
-
| "ResourceNotFound"
|
|
4
|
-
| "WrongFormat"
|
|
5
|
-
| "TooMuchWork"
|
|
6
|
-
| "Timeout"
|
|
7
|
-
| "Conflict"
|
|
8
|
-
| "NotImplemented"
|
|
9
|
-
| "BadRequest"
|
|
10
|
-
| "WrongActionOrder"
|
|
11
|
-
| "InvalidOperation"
|
|
12
|
-
| "UnexpectedError"
|
|
13
|
-
| "IPRestricted"
|
|
14
|
-
| "PlanRestricted"
|
|
15
|
-
| "MissingWorkspacePermission"
|
|
16
|
-
| "MissingExporterPermission"
|
|
17
|
-
| "MissingIntegration"
|
|
18
|
-
| "MissingIntegrationAccess"
|
|
19
|
-
| "NoAccess"
|
|
20
|
-
| "MissingCredentials"
|
|
21
|
-
| "ValidationError"
|
|
22
|
-
| "ThirdPartyError";
|
|
23
|
-
|
|
24
|
-
export class SupernovaException extends Error {
|
|
25
|
-
static wrongFormat(message?: string): SupernovaException {
|
|
26
|
-
return new SupernovaException("WrongFormat", message);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
static validationError(message?: string): SupernovaException {
|
|
30
|
-
return new SupernovaException("ValidationError", message);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
static accessDenied(message?: string): SupernovaException {
|
|
34
|
-
return new SupernovaException("AccessDenied", message);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
static tooMuchWork(message?: string): SupernovaException {
|
|
38
|
-
return new SupernovaException("TooMuchWork", message);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
static notFound(message?: string): SupernovaException {
|
|
42
|
-
return new SupernovaException("ResourceNotFound", message);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
static timeout(message?: string): SupernovaException {
|
|
46
|
-
return new SupernovaException("Timeout", message);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
static conflict(message?: string): SupernovaException {
|
|
50
|
-
return new SupernovaException("Conflict", message);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
static notImplemented(message?: string): SupernovaException {
|
|
54
|
-
return new SupernovaException("NotImplemented", message);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
static wrongActionOrder(message?: string): SupernovaException {
|
|
58
|
-
return new SupernovaException("WrongActionOrder", message);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
static invalidOperation(message?: string): SupernovaException {
|
|
62
|
-
return new SupernovaException("InvalidOperation", message);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
static shouldNotHappen(message?: string): SupernovaException {
|
|
66
|
-
return new SupernovaException("UnexpectedError", message);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
static ipRestricted(message?: string): SupernovaException {
|
|
70
|
-
return new SupernovaException("IPRestricted", message);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
static planRestricted(message?: string): SupernovaException {
|
|
74
|
-
return new SupernovaException("PlanRestricted", message);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
static missingWorkspacePermission(message?: string): SupernovaException {
|
|
78
|
-
return new SupernovaException("MissingWorkspacePermission", message);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
static missingExporterPermission(message?: string): SupernovaException {
|
|
82
|
-
return new SupernovaException("MissingExporterPermission", message);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
static missingIntegration(message?: string): SupernovaException {
|
|
86
|
-
return new SupernovaException("MissingIntegration", message);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
static missingIntegrationAccess(message?: string): SupernovaException {
|
|
90
|
-
return new SupernovaException("MissingIntegrationAccess", message);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
static noAccess(message?: string): SupernovaException {
|
|
94
|
-
return new SupernovaException("NoAccess", message);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
static missingCredentials(message?: string): SupernovaException {
|
|
98
|
-
return new SupernovaException("MissingCredentials", message);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
static thirdPartyError(message?: string): SupernovaException {
|
|
102
|
-
return new SupernovaException("ThirdPartyError", message);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
//
|
|
106
|
-
// To refactor
|
|
107
|
-
//
|
|
108
|
-
|
|
109
|
-
static badRequest(message?: string): SupernovaException {
|
|
110
|
-
return new SupernovaException("BadRequest", message);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
//
|
|
114
|
-
// Properties
|
|
115
|
-
//
|
|
116
|
-
|
|
117
|
-
constructor(readonly type: SupernovaExceptionType, message?: string) {
|
|
118
|
-
super(`${type}: ${message}`);
|
|
119
|
-
}
|
|
120
|
-
}
|
package/src/utils/index.ts
DELETED
package/src/utils/naming.ts
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
// this has been ported from the Dart cloud app
|
|
2
|
-
export function getCodenameFromText(name: string): string {
|
|
3
|
-
// Turn all characters with diacritics into their simple form (ě -> e, ö -> o, etc.)
|
|
4
|
-
let codeName = removeDiacritics(name);
|
|
5
|
-
|
|
6
|
-
// Remove all invalid characters
|
|
7
|
-
codeName = codeName.replace(/[^a-zA-Z0-9$_ ]+/g, "");
|
|
8
|
-
// Remove all starting numbers
|
|
9
|
-
codeName = codeName.replace(/^[0-9 ]+/g, "");
|
|
10
|
-
// Change to CamelCase
|
|
11
|
-
codeName = toCamelCase(codeName.toLowerCase());
|
|
12
|
-
// Remove all spaces
|
|
13
|
-
codeName = codeName.replace(/ /g, "");
|
|
14
|
-
|
|
15
|
-
if (codeName) {
|
|
16
|
-
// Lowercase the first letter
|
|
17
|
-
codeName = codeName.charAt(0).toLowerCase() + codeName.slice(1);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return codeName;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function toCamelCase(str: string): string {
|
|
24
|
-
return str.replace(/(?:^\w|[A-Z]|\b\w|\s+)/g, function (match, index) {
|
|
25
|
-
if (+match === 0) return ""; // or if (/\s+/.test(match)) for white spaces
|
|
26
|
-
return index === 0 ? match.toLowerCase() : match.toUpperCase();
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function removeDiacritics(str: string): string {
|
|
31
|
-
const diacriticsMap = [
|
|
32
|
-
{
|
|
33
|
-
base: "A",
|
|
34
|
-
letters:
|
|
35
|
-
/[\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F]/g,
|
|
36
|
-
},
|
|
37
|
-
{ base: "AA", letters: /[\uA732]/g },
|
|
38
|
-
{ base: "AE", letters: /[\u00C6\u01FC\u01E2]/g },
|
|
39
|
-
{ base: "AO", letters: /[\uA734]/g },
|
|
40
|
-
{ base: "AU", letters: /[\uA736]/g },
|
|
41
|
-
{ base: "AV", letters: /[\uA738\uA73A]/g },
|
|
42
|
-
{ base: "AY", letters: /[\uA73C]/g },
|
|
43
|
-
{
|
|
44
|
-
base: "B",
|
|
45
|
-
letters: /[\u0042\u24B7\uFF22\u1E02\u1E04\u1E06\u0243\u0182\u0181]/g,
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
base: "C",
|
|
49
|
-
letters: /[\u0043\u24B8\uFF23\u0106\u0108\u010A\u010C\u00C7\u1E08\u0187\u023B\uA73E]/g,
|
|
50
|
-
},
|
|
51
|
-
/* ... */
|
|
52
|
-
{
|
|
53
|
-
base: "Z",
|
|
54
|
-
letters: /[\u005A\u24CF\uFF3A\u0179\u1E90\u017B\u017D\u1E92\u1E94\u01B5\u0224\u2C7F\u2C6B\uA762]/g,
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
base: "a",
|
|
58
|
-
letters:
|
|
59
|
-
/[\u0061\u24D0\uFF41\u1E9A\u00E0\u00E1\u00E2\u1EA7\u1EA5\u1EAB\u1EA9\u00E3\u0101\u0103\u1EB1\u1EAF\u1EB5\u1EB3\u0227\u01E1\u00E4\u01DF\u1EA3\u00E5\u01FB\u01CE\u0201\u0203\u1EA1\u1EAD\u1EB7\u1E01\u0105\u2C65\u0250]/g,
|
|
60
|
-
},
|
|
61
|
-
/* ... */
|
|
62
|
-
{
|
|
63
|
-
base: "z",
|
|
64
|
-
letters: /[\u007A\u24E9\uFF5A\u017A\u1E91\u017C\u017E\u1E93\u1E95\u01B6\u0225\u0240\u2C6C\uA763]/g,
|
|
65
|
-
},
|
|
66
|
-
];
|
|
67
|
-
|
|
68
|
-
diacriticsMap.forEach(diacritic => {
|
|
69
|
-
str = str.replace(diacritic.letters, diacritic.base);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
return str;
|
|
73
|
-
}
|