@supernova-studio/model 0.0.4

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.
Files changed (165) hide show
  1. package/index.ts +1 -0
  2. package/package.json +23 -0
  3. package/src/auth/index.ts +1 -0
  4. package/src/auth/plugin-oauth-request.ts +14 -0
  5. package/src/billing/card.ts +12 -0
  6. package/src/billing/checkoutSession.ts +16 -0
  7. package/src/billing/customer.ts +28 -0
  8. package/src/billing/features.ts +43 -0
  9. package/src/billing/index.ts +9 -0
  10. package/src/billing/invoice.ts +34 -0
  11. package/src/billing/portalSession.ts +19 -0
  12. package/src/billing/price.ts +24 -0
  13. package/src/billing/product.ts +5 -0
  14. package/src/billing/subscription.ts +65 -0
  15. package/src/codegen/export-jobs.ts +26 -0
  16. package/src/codegen/exporter-workspace-membership-role.ts +4 -0
  17. package/src/codegen/exporter-workspace-membership.ts +14 -0
  18. package/src/codegen/exporter.ts +52 -0
  19. package/src/codegen/git-providers.ts +11 -0
  20. package/src/codegen/index.ts +6 -0
  21. package/src/codegen/pulsar.ts +59 -0
  22. package/src/common/entity.ts +9 -0
  23. package/src/common/index.ts +2 -0
  24. package/src/common/object-meta.ts +8 -0
  25. package/src/custom-domains/custom-domains.ts +24 -0
  26. package/src/custom-domains/index.ts +1 -0
  27. package/src/docs-server/index.ts +1 -0
  28. package/src/docs-server/session.ts +39 -0
  29. package/src/dsm/assets/asset-reference.ts +18 -0
  30. package/src/dsm/assets/asset-value.ts +3 -0
  31. package/src/dsm/assets/asset.ts +48 -0
  32. package/src/dsm/assets/index.ts +3 -0
  33. package/src/dsm/brand.ts +7 -0
  34. package/src/dsm/data-sources/data-source.ts +158 -0
  35. package/src/dsm/data-sources/import-job.ts +28 -0
  36. package/src/dsm/data-sources/import-summary.ts +70 -0
  37. package/src/dsm/data-sources/index.ts +3 -0
  38. package/src/dsm/design-system.ts +33 -0
  39. package/src/dsm/desing-system-create.ts +22 -0
  40. package/src/dsm/desing-system-update.ts +25 -0
  41. package/src/dsm/documentation/block-definitions/aux.ts +8 -0
  42. package/src/dsm/documentation/block-definitions/definition.ts +104 -0
  43. package/src/dsm/documentation/block-definitions/index.ts +4 -0
  44. package/src/dsm/documentation/block-definitions/item.ts +113 -0
  45. package/src/dsm/documentation/block-definitions/variant.ts +78 -0
  46. package/src/dsm/documentation/group.ts +19 -0
  47. package/src/dsm/documentation/index.ts +3 -0
  48. package/src/dsm/documentation/page.ts +18 -0
  49. package/src/dsm/elements/base.ts +49 -0
  50. package/src/dsm/elements/component.ts +48 -0
  51. package/src/dsm/elements/data/base.ts +18 -0
  52. package/src/dsm/elements/data/blur.ts +16 -0
  53. package/src/dsm/elements/data/border-radius.ts +15 -0
  54. package/src/dsm/elements/data/border-width.ts +15 -0
  55. package/src/dsm/elements/data/border.ts +21 -0
  56. package/src/dsm/elements/data/color.ts +13 -0
  57. package/src/dsm/elements/data/component.ts +23 -0
  58. package/src/dsm/elements/data/dimension.ts +15 -0
  59. package/src/dsm/elements/data/documentation-block-v1.ts +325 -0
  60. package/src/dsm/elements/data/documentation-block-v2.ts +57 -0
  61. package/src/dsm/elements/data/documentation-page-v1.ts +13 -0
  62. package/src/dsm/elements/data/documentation-page-v2.ts +11 -0
  63. package/src/dsm/elements/data/documentation.ts +8 -0
  64. package/src/dsm/elements/data/duration.ts +15 -0
  65. package/src/dsm/elements/data/figma-file-structure.ts +65 -0
  66. package/src/dsm/elements/data/figma-node-reference.ts +20 -0
  67. package/src/dsm/elements/data/font-family.ts +8 -0
  68. package/src/dsm/elements/data/font-size.ts +15 -0
  69. package/src/dsm/elements/data/font-weight.ts +8 -0
  70. package/src/dsm/elements/data/gradient.ts +32 -0
  71. package/src/dsm/elements/data/group.ts +17 -0
  72. package/src/dsm/elements/data/index.ts +36 -0
  73. package/src/dsm/elements/data/letter-spacing.ts +15 -0
  74. package/src/dsm/elements/data/line-height.ts +15 -0
  75. package/src/dsm/elements/data/opacity.ts +12 -0
  76. package/src/dsm/elements/data/paragraph-indent.ts +15 -0
  77. package/src/dsm/elements/data/paragraph-spacing.ts +15 -0
  78. package/src/dsm/elements/data/product-copy.ts +8 -0
  79. package/src/dsm/elements/data/shadow.ts +23 -0
  80. package/src/dsm/elements/data/size.ts +15 -0
  81. package/src/dsm/elements/data/space.ts +15 -0
  82. package/src/dsm/elements/data/string.ts +8 -0
  83. package/src/dsm/elements/data/text-case.ts +10 -0
  84. package/src/dsm/elements/data/text-decoration.ts +10 -0
  85. package/src/dsm/elements/data/typography.ts +28 -0
  86. package/src/dsm/elements/data/visibility.ts +10 -0
  87. package/src/dsm/elements/data/z-index.ts +15 -0
  88. package/src/dsm/elements/documentation-page-v1.ts +30 -0
  89. package/src/dsm/elements/documentation-page-v2.ts +16 -0
  90. package/src/dsm/elements/figma-file-structures.ts +39 -0
  91. package/src/dsm/elements/figma-node-reference.ts +17 -0
  92. package/src/dsm/elements/group.ts +59 -0
  93. package/src/dsm/elements/index.ts +13 -0
  94. package/src/dsm/elements/page-block-v2.ts +24 -0
  95. package/src/dsm/elements/primitives/index.ts +2 -0
  96. package/src/dsm/elements/primitives/point.ts +8 -0
  97. package/src/dsm/elements/primitives/size.ts +28 -0
  98. package/src/dsm/elements/raw-element.ts +126 -0
  99. package/src/dsm/elements/theme.ts +74 -0
  100. package/src/dsm/elements/tokens.ts +288 -0
  101. package/src/dsm/import/asset.ts +6 -0
  102. package/src/dsm/import/base.ts +24 -0
  103. package/src/dsm/import/component.ts +36 -0
  104. package/src/dsm/import/data-source.ts +9 -0
  105. package/src/dsm/import/figma-frames.ts +74 -0
  106. package/src/dsm/import/image.ts +72 -0
  107. package/src/dsm/import/index.ts +11 -0
  108. package/src/dsm/import/origin.ts +5 -0
  109. package/src/dsm/import/support/figma-files.ts +16 -0
  110. package/src/dsm/import/support/import-context.ts +75 -0
  111. package/src/dsm/import/support/import-model-collections.ts +46 -0
  112. package/src/dsm/import/support/index.ts +3 -0
  113. package/src/dsm/import/theme.ts +76 -0
  114. package/src/dsm/import/tokens.ts +49 -0
  115. package/src/dsm/import/warning.ts +28 -0
  116. package/src/dsm/index.ts +15 -0
  117. package/src/dsm/properties/index.ts +3 -0
  118. package/src/dsm/properties/property-definition.ts +44 -0
  119. package/src/dsm/properties/property-reference.ts +5 -0
  120. package/src/dsm/properties/property-value.ts +27 -0
  121. package/src/dsm/published-doc-page.ts +25 -0
  122. package/src/dsm/published-doc.ts +30 -0
  123. package/src/dsm/reference.ts +9 -0
  124. package/src/dsm/version.ts +14 -0
  125. package/src/dsm/views/column.ts +43 -0
  126. package/src/dsm/views/index.ts +2 -0
  127. package/src/dsm/views/view.ts +11 -0
  128. package/src/feature-flags/feature-flags.ts +14 -0
  129. package/src/feature-flags/index.ts +1 -0
  130. package/src/helpers/common.ts +1 -0
  131. package/src/helpers/db.ts +37 -0
  132. package/src/helpers/index.ts +4 -0
  133. package/src/helpers/nullish-to-optional.ts +9 -0
  134. package/src/helpers/slug-helper.ts +641 -0
  135. package/src/index.ts +16 -0
  136. package/src/integrations/external-oauth-request.ts +12 -0
  137. package/src/integrations/index.ts +3 -0
  138. package/src/integrations/oauth-providers.ts +13 -0
  139. package/src/integrations/oauth-token.ts +15 -0
  140. package/src/multiplayer/design-system-version-room.ts +13 -0
  141. package/src/multiplayer/documentation-page-room.ts +14 -0
  142. package/src/multiplayer/index.ts +2 -0
  143. package/src/npm/index.ts +2 -0
  144. package/src/npm/npm-package.ts +30 -0
  145. package/src/npm/npm-proxy-token-payload.ts +7 -0
  146. package/src/tokens/index.ts +1 -0
  147. package/src/tokens/personal-access-token.ts +17 -0
  148. package/src/users/index.ts +5 -0
  149. package/src/users/linked-integrations.ts +36 -0
  150. package/src/users/user-identity.ts +8 -0
  151. package/src/users/user-profile.ts +26 -0
  152. package/src/users/user-with-pat.ts +7 -0
  153. package/src/users/user.ts +17 -0
  154. package/src/utils/content-loader-instruction.ts +31 -0
  155. package/src/utils/index.ts +1 -0
  156. package/src/workspace/index.ts +9 -0
  157. package/src/workspace/npm-registry-settings.ts +45 -0
  158. package/src/workspace/sso-provider.ts +13 -0
  159. package/src/workspace/user-invite.ts +18 -0
  160. package/src/workspace/workspace-context.ts +10 -0
  161. package/src/workspace/workspace-create.ts +27 -0
  162. package/src/workspace/workspace-invitations.ts +14 -0
  163. package/src/workspace/workspace-membership.ts +11 -0
  164. package/src/workspace/workspace-role.ts +6 -0
  165. package/src/workspace/workspace.ts +48 -0
package/index.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './src';
package/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "@supernova-studio/model",
3
+ "version": "0.0.4",
4
+ "description": "Supernova Data Models",
5
+ "main": "index.ts",
6
+ "source": "index.ts",
7
+ "files": [
8
+ "src"
9
+ ],
10
+ "scripts": {
11
+ "build": "tsc"
12
+ },
13
+ "author": "",
14
+ "license": "ISC",
15
+ "dependencies": {
16
+ "typescript": "^5.0.4",
17
+ "zod": "^3.22.4",
18
+ "@sindresorhus/slugify": "1.1.2"
19
+ },
20
+ "devDependencies": {
21
+ "fs": "^0.0.1-security"
22
+ }
23
+ }
@@ -0,0 +1 @@
1
+ export * from "./plugin-oauth-request";
@@ -0,0 +1,14 @@
1
+ import { z } from "zod";
2
+
3
+ export const PluginOAuthRequestSchema = z.object({
4
+ id: z.string(),
5
+ codeChallenge: z.string(),
6
+ readKey: z.string(),
7
+ writeKey: z.string(),
8
+ readKeyConsumed: z.boolean(),
9
+ writeKeyConsumed: z.boolean(),
10
+ oAuthCode: z.string().optional(),
11
+ createdAt: z.date(),
12
+ });
13
+
14
+ export type PluginOAuthRequest = z.infer<typeof PluginOAuthRequestSchema>;
@@ -0,0 +1,12 @@
1
+ import { z } from "zod";
2
+
3
+ export const CardSchema = z.object({
4
+ cardId: z.string().nullish(),
5
+ last4: z.string().length(4).nullish(),
6
+ expiryMonth: z.string().nullish(),
7
+ expiryYear: z.string().nullish(),
8
+ brand: z.string().nullish(),
9
+ name: z.string().nullish(),
10
+ });
11
+
12
+ export type Card = z.infer<typeof CardSchema>;
@@ -0,0 +1,16 @@
1
+ import { z } from "zod";
2
+
3
+ export const PostStripeCheckoutBodyInputSchema = z.object({
4
+ priceId: z.string(),
5
+ successUrl: z.string().url(),
6
+ cancelUrl: z.string().url(),
7
+ quantity: z.number().int().min(1).optional(),
8
+ });
9
+
10
+ export const PostStripeCheckoutOutputSchema = z.object({
11
+ id: z.string(),
12
+ url: z.string().nullish(),
13
+ });
14
+
15
+ export type StripeCheckoutInput = z.infer<typeof PostStripeCheckoutBodyInputSchema>;
16
+ export type StripeCheckoutOutput = z.infer<typeof PostStripeCheckoutOutputSchema>;
@@ -0,0 +1,28 @@
1
+ import { z } from "zod";
2
+
3
+ export const Customer = z.object({
4
+ id: z.string(),
5
+ });
6
+
7
+ export const Address = z.object({
8
+ street1: z.string().optional(),
9
+ street2: z.string().optional(),
10
+ city: z.string().optional(),
11
+ postal: z.string().optional(),
12
+ country: z.string().optional(),
13
+ state: z.string().optional(),
14
+ });
15
+
16
+ export const BillingDetails = z.object({
17
+ address: Address.optional(),
18
+ email: z.string().optional(),
19
+ companyName: z.string().optional(),
20
+ companyId: z.string().optional(),
21
+ notes: z.string().optional(),
22
+ vat: z.string().optional(),
23
+ poNumber: z.string().optional(),
24
+ });
25
+
26
+ export type Customer = z.infer<typeof Customer>;
27
+ export type Address = z.infer<typeof Address>;
28
+ export type BillingDetails = z.infer<typeof BillingDetails>;
@@ -0,0 +1,43 @@
1
+ import { z } from "zod";
2
+
3
+ const featureLimitedSchema = z.object({
4
+ max: z.number(),
5
+ errorMessage: z.string(),
6
+ errorReason: z.string(),
7
+ });
8
+
9
+ const featureToggleSchema = z.object({
10
+ enabled: z.boolean(),
11
+ errorMessage: z.string(),
12
+ errorReason: z.string(),
13
+ });
14
+
15
+ const featureWithImportJobsSchema = featureLimitedSchema.extend({
16
+ noImportJobsErrorMessage: z.string(),
17
+ noImportJobsErrorReason: z.string(),
18
+ });
19
+
20
+ export const FeaturesSummary = z.object({
21
+ designSystems: featureLimitedSchema,
22
+ designSystemSources: featureWithImportJobsSchema,
23
+ designSystemVersions: featureLimitedSchema,
24
+ themes: featureLimitedSchema,
25
+ brands: featureLimitedSchema,
26
+ codegenSchedules: featureLimitedSchema,
27
+ publicDocumentation: featureToggleSchema,
28
+ customDocumentationUrl: featureToggleSchema,
29
+ customDocumentationViewButton: featureToggleSchema,
30
+ designSystemSourceAutoImport: featureToggleSchema,
31
+ designSystemSlug: featureToggleSchema,
32
+ ipWhitelisting: featureToggleSchema,
33
+ npmRegistry: featureToggleSchema,
34
+ sso: featureToggleSchema,
35
+ workspacePaidSeats: featureLimitedSchema,
36
+ workspaceViewers: featureLimitedSchema,
37
+ customDocumentationExporter: featureToggleSchema,
38
+ });
39
+
40
+ export type FeatureLimitedDetails = z.infer<typeof featureLimitedSchema>;
41
+ export type FeatureToggleDetails = z.infer<typeof featureToggleSchema>;
42
+ export type FeatureWithImportJobsDetails = z.infer<typeof featureWithImportJobsSchema>;
43
+ export type FeaturesSummary = z.infer<typeof FeaturesSummary>;
@@ -0,0 +1,9 @@
1
+ export * from "./card";
2
+ export * from "./checkoutSession";
3
+ export * from "./customer";
4
+ export * from "./features";
5
+ export * from "./invoice";
6
+ export * from "./portalSession";
7
+ export * from "./price";
8
+ export * from "./product";
9
+ export * from "./subscription";
@@ -0,0 +1,34 @@
1
+ import { z } from "zod";
2
+ import { CardSchema } from "./card";
3
+
4
+ export const InvoiceSchema = z.object({
5
+ id: z.string(),
6
+ number: z.string(),
7
+ amount_due: z.number(),
8
+ date: z.date(),
9
+ hostedUrl: z.string().url(),
10
+ card: CardSchema.nullish(),
11
+ });
12
+
13
+ export const PeriodSchema = z.object({
14
+ start: z.date(),
15
+ end: z.date(),
16
+ });
17
+
18
+ export const InvoiceLineSchema = z.object({
19
+ amount: z.number(),
20
+ period: PeriodSchema,
21
+ proration: z.boolean(),
22
+ description: z.string(),
23
+ type: z.string(),
24
+ });
25
+
26
+ export const InvoiceCouponSchema = z.object({
27
+ amount_off: z.number(),
28
+ percent_off: z.number(),
29
+ name: z.string(),
30
+ });
31
+
32
+ export type Invoice = z.infer<typeof InvoiceSchema>;
33
+ export type InvoiceLine = z.infer<typeof InvoiceLineSchema>;
34
+ export type InvoiceCoupon = z.infer<typeof InvoiceCouponSchema>;
@@ -0,0 +1,19 @@
1
+ import { z } from "zod";
2
+
3
+ export const PostStripePortalUpdateSessionBodyInputSchema = z.object({
4
+ priceId: z.string(),
5
+ numberOfSeats: z.number().int(),
6
+ });
7
+ export const PostStripePortalSessionBodyInputSchema = z.object({
8
+ returnUrl: z.string().url(),
9
+ update: PostStripePortalUpdateSessionBodyInputSchema.optional(),
10
+ cancel: z.boolean().optional(),
11
+ });
12
+
13
+ export const PostStripePortalSessionOutputSchema = z.object({
14
+ id: z.string(),
15
+ url: z.string().nullish(),
16
+ });
17
+
18
+ export type StripePortalSessionInput = z.infer<typeof PostStripePortalSessionBodyInputSchema>;
19
+ export type StripePortalSessionOutput = z.infer<typeof PostStripePortalSessionOutputSchema>;
@@ -0,0 +1,24 @@
1
+ import { z } from "zod";
2
+
3
+ export const BillingIntervalSchema = z.enum(["daily", "monthly", "weekly", "yearly"]);
4
+
5
+ export const PriceSchema = z.object({
6
+ stripePriceId: z.string(),
7
+ stripeProductId: z.string(),
8
+ stripeProductName: z.string().optional(),
9
+ stripeProductDescription: z.string().optional(),
10
+ active: z.boolean(),
11
+ amount: z.number(),
12
+ interval: BillingIntervalSchema,
13
+ isPricePerCreator: z.boolean().optional(),
14
+ isTrial: z.boolean().optional(),
15
+ isHidden: z.boolean().optional(),
16
+ minimumSeats: z.number().optional(),
17
+ legacyVersion: z.string().optional(),
18
+ featuresSet: z.string().optional(),
19
+ stripeProductFeatures: z.array(z.string()).optional(),
20
+ stripeProductAdditionalFeatures: z.array(z.string()).optional(),
21
+ });
22
+
23
+ export type BillingInterval = z.infer<typeof BillingIntervalSchema>;
24
+ export type Price = z.infer<typeof PriceSchema>;
@@ -0,0 +1,5 @@
1
+ import { z } from "zod";
2
+
3
+ export const ProductCodeSchema = z.enum(["free", "team", "team_test", "company", "enterprise"]);
4
+ export type ProductCode = z.infer<typeof ProductCodeSchema>;
5
+ export const ProductCode = ProductCodeSchema.enum;
@@ -0,0 +1,65 @@
1
+ import { CardSchema } from "./card";
2
+ import { ProductCode, ProductCodeSchema } from "./product";
3
+ import { FeaturesSummary } from "./features";
4
+ import { BillingIntervalSchema } from "./price";
5
+ import { z } from "zod";
6
+ export const StripeSubscriptionStatusSchema = z.enum([
7
+ "trialing",
8
+ "active",
9
+ "past_due",
10
+ "canceled",
11
+ "unpaid",
12
+ "incomplete_expired",
13
+ "incomplete",
14
+ "unknown",
15
+ ]);
16
+
17
+ export const InternalStatusSchema = z.enum(["active", "suspended", "gracePeriod", "cancelled", "downgraded_to_free"]);
18
+
19
+ export const BillingTypeSchema = z.enum(["Auto", "Invoice"]);
20
+
21
+ export type StripeSubscriptionStatus = z.infer<typeof StripeSubscriptionStatusSchema>;
22
+ export type InternalStatus = z.infer<typeof InternalStatusSchema>;
23
+ export type BillingType = z.infer<typeof BillingTypeSchema>;
24
+
25
+ export const StripeSubscriptionStatus = StripeSubscriptionStatusSchema.enum;
26
+ export const InternalStatus = InternalStatusSchema.enum;
27
+ export const BillingType = BillingTypeSchema.enum;
28
+
29
+ export const Subscription = z.object({
30
+ stripeSubscriptionId: z.string().nullish(),
31
+ stripeCustomerId: z.string().nullish(),
32
+
33
+ status: InternalStatusSchema.optional(),
34
+ subscriptionStatus: StripeSubscriptionStatusSchema.optional(), // the stripe API official status
35
+ internalStatus: InternalStatusSchema.optional(), // TODO: delete when create/get workspace will stop using it in the former API
36
+
37
+ product: ProductCodeSchema,
38
+ featuresSummary: FeaturesSummary.optional(),
39
+ stripeProductDescription: z.string().optional(),
40
+ stripeProductFeatures: z.array(z.string()).optional(),
41
+ stripeProductAdditionalFeatures: z.array(z.string()).optional(),
42
+ stripeSubscriptionMainItemId: z.string().optional(),
43
+ planPriceId: z.string(),
44
+ planInterval: BillingIntervalSchema,
45
+ isPricePerCreator: z.boolean().optional(),
46
+ legacyVersion: z.string().optional(),
47
+
48
+ seats: z.number(),
49
+ seatLimit: z.number(),
50
+
51
+ currentPeriodStart: z.string().optional(),
52
+ currentPeriodEnd: z.string().optional(),
53
+ subscriptionStatusUpdatedAt: z.string().optional(),
54
+ cancelAt: z.string().nullish(),
55
+
56
+ card: CardSchema.optional(),
57
+
58
+ // New
59
+ amount: z.number().nullish(),
60
+ isTrial: z.boolean().optional(),
61
+ billingType: BillingTypeSchema.optional(),
62
+ daysUntilDue: z.number().optional(),
63
+ });
64
+
65
+ export type Subscription = z.infer<typeof Subscription>;
@@ -0,0 +1,26 @@
1
+ import { PublishedDocEnvironment } from "../dsm";
2
+ import { z } from "zod";
3
+ export const ExportJobStatus = z.union([
4
+ z.literal("Success"),
5
+ z.literal("InProgress"),
6
+ z.literal("Timeout"),
7
+ z.literal("Failed"),
8
+ ]);
9
+
10
+ export type ExportJobStatus = z.infer<typeof ExportJobStatus>;
11
+
12
+ export const ExportJob = z.object({
13
+ id: z.string(),
14
+ workspaceId: z.string(),
15
+ designSystemId: z.string(),
16
+ designSystemVersionId: z.string(),
17
+ status: ExportJobStatus,
18
+ docsUrl: z.string().nullish(),
19
+ scheduleId: z.string().nullish(),
20
+ exporterId: z.string().nullish(),
21
+ createdAt: z.date(),
22
+ environment: PublishedDocEnvironment,
23
+ finishedAt: z.date().nullish(),
24
+ });
25
+
26
+ export type ExportJob = z.infer<typeof ExportJob>;
@@ -0,0 +1,4 @@
1
+ import { z } from "zod";
2
+
3
+ export const ExporterWorkspaceMembershipRole = z.enum(["Owner", "OwnerArchived", "User"]);
4
+ export type ExporterWorkspaceMembershipRole = z.infer<typeof ExporterWorkspaceMembershipRole>;
@@ -0,0 +1,14 @@
1
+ import { z } from "zod";
2
+ import { ExporterWorkspaceMembershipRole } from "./exporter-workspace-membership-role";
3
+ import { DbCreateInputOmit } from "../helpers";
4
+
5
+ export const ExporterWorkspaceMembership = z.object({
6
+ id: z.string(),
7
+ workspaceId: z.string(),
8
+ exporterId: z.string(),
9
+ role: ExporterWorkspaceMembershipRole,
10
+ });
11
+
12
+ export type ExporterWorkspaceMembership = z.infer<typeof ExporterWorkspaceMembership>;
13
+
14
+ export type CreateExporterMembership = DbCreateInputOmit<ExporterWorkspaceMembership>;
@@ -0,0 +1,52 @@
1
+ import { z } from "zod";
2
+ import { GitProvider } from "./git-providers";
3
+ import { PulsarContributionBlock, PulsarContributionConfigurationProperty, PulsarContributionVariant } from "./pulsar";
4
+ import { nullishToOptional } from "../helpers";
5
+
6
+ export const ExporterType = z.enum(["code", "documentation"]);
7
+ export const ExporterSource = z.enum(["git", "upload"]);
8
+ export const ExporterTag = z.string().regex(/^[0-9a-zA-Z]+(\s[0-9a-zA-Z]+)*$/);
9
+
10
+ export const ExporterDetails = z.object({
11
+ packageId: z.string().max(255),
12
+ version: z.string(),
13
+ description: z.string(),
14
+ author: nullishToOptional(z.string()),
15
+ organization: nullishToOptional(z.string()),
16
+ homepage: nullishToOptional(z.string()),
17
+ readme: nullishToOptional(z.string()),
18
+ tags: z.array(ExporterTag).default([]),
19
+
20
+ routingVersion: nullishToOptional(z.string()),
21
+
22
+ iconURL: nullishToOptional(z.string()),
23
+ configurationProperties: z.array(PulsarContributionConfigurationProperty).default([]),
24
+ customBlocks: z.array(PulsarContributionBlock).default([]),
25
+ blockVariants: z.record(z.string(), z.array(PulsarContributionVariant)).default({}),
26
+
27
+ usesBrands: z.boolean().default(false),
28
+ usesThemes: z.boolean().default(false),
29
+
30
+ source: ExporterSource,
31
+
32
+ gitProvider: nullishToOptional(GitProvider),
33
+ gitUrl: nullishToOptional(z.string()),
34
+ gitBranch: nullishToOptional(z.string()),
35
+ gitDirectory: nullishToOptional(z.string()),
36
+ });
37
+
38
+ export const Exporter = z.object({
39
+ id: z.string(),
40
+ createdAt: z.coerce.date(),
41
+ name: z.string(),
42
+ isPrivate: z.boolean(),
43
+ details: ExporterDetails,
44
+ exporterType: ExporterType.default("code"),
45
+ storagePath: z.string().default(""),
46
+ });
47
+
48
+ export type ExporterType = z.infer<typeof ExporterType>;
49
+ export type ExporterSource = z.infer<typeof ExporterSource>;
50
+ export type ExporterTag = z.infer<typeof ExporterTag>;
51
+ export type ExporterDetails = z.infer<typeof ExporterDetails>;
52
+ export type Exporter = z.infer<typeof Exporter>;
@@ -0,0 +1,11 @@
1
+ import { z } from "zod";
2
+
3
+ export enum GitProviderNames {
4
+ Azure = "azure",
5
+ Github = "github",
6
+ Gitlab = "gitlab",
7
+ Bitbucket = "bitbucket",
8
+ }
9
+
10
+ export const GitProvider = z.nativeEnum(GitProviderNames);
11
+ export type GitProvider = z.infer<typeof GitProvider>;
@@ -0,0 +1,6 @@
1
+ export * from "./export-jobs";
2
+ export * from "./exporter-workspace-membership-role";
3
+ export * from "./exporter-workspace-membership";
4
+ export * from "./exporter";
5
+ export * from "./git-providers";
6
+ export * from "./pulsar";
@@ -0,0 +1,59 @@
1
+ import { z } from "zod";
2
+
3
+ export const PulsarContributionVariant = z.object({
4
+ key: z.string(),
5
+ name: z.string(),
6
+ isDefault: z.boolean().optional(),
7
+ description: z.string().optional(),
8
+ thumbnailURL: z.string().optional(),
9
+ });
10
+ export type PulsarContributionVariant = z.infer<typeof PulsarContributionVariant>;
11
+
12
+ export const PulsarPropertyType = z.enum([
13
+ "string",
14
+ "number",
15
+ "boolean",
16
+ "image",
17
+ "enum",
18
+ "color",
19
+ "typography",
20
+ "component",
21
+ "componentProperties",
22
+ "tokenProperties",
23
+ "tokenType",
24
+ ]);
25
+ export type PulsarPropertyType = z.infer<typeof PulsarPropertyType>;
26
+
27
+ // export type PulsarPropertyValueType =
28
+ // | string
29
+ // | number
30
+ // | boolean
31
+ // | PulsarPropertyImageValue
32
+ // | ColorTokenData // TODO: Should we do smth here? Update Pulsar to get value?!
33
+ // | TypographyTokenData;
34
+
35
+ export const BasePulsarProperty = z.object({
36
+ label: z.string(),
37
+ key: z.string(),
38
+ description: z.string().optional(),
39
+ type: PulsarPropertyType,
40
+ values: z.array(z.string()).optional(),
41
+ default: z.union([z.string(), z.boolean(), z.number()]).nullish(), // PulsarPropertyValueType //is optional?
42
+ inputType: z.enum(["code", "plain"]).optional(), //is optional?
43
+ isMultiline: z.boolean().optional(),
44
+ });
45
+ export type BasePulsarProperty = z.infer<typeof BasePulsarProperty>;
46
+
47
+ export const PulsarContributionBlock = z.object({
48
+ title: z.string(),
49
+ key: z.string(),
50
+ category: z.string(),
51
+ description: z.string().optional(),
52
+ iconURL: z.string(),
53
+ mode: z.enum(["array", "block"]),
54
+ properties: z.array(BasePulsarProperty),
55
+ });
56
+ export type PulsarContributionBlock = z.infer<typeof PulsarContributionBlock>;
57
+
58
+ export const PulsarContributionConfigurationProperty = BasePulsarProperty.extend({ category: z.string() });
59
+ export type PulsarContributionConfigurationProperty = z.infer<typeof PulsarContributionConfigurationProperty>;
@@ -0,0 +1,9 @@
1
+ import { z } from "zod";
2
+
3
+ export const Entity = z.object({
4
+ id: z.string(),
5
+ createdAt: z.date(),
6
+ updatedAt: z.date(),
7
+ });
8
+
9
+ export type Entity = z.infer<typeof Entity>;
@@ -0,0 +1,2 @@
1
+ export * from "./entity";
2
+ export * from "./object-meta";
@@ -0,0 +1,8 @@
1
+ import { z } from "zod";
2
+
3
+ export const ObjectMeta = z.object({
4
+ name: z.string(),
5
+ description: z.string().optional(),
6
+ });
7
+
8
+ export type ObjectMeta = z.infer<typeof ObjectMeta>;
@@ -0,0 +1,24 @@
1
+ import { z } from "zod";
2
+
3
+ export type CustomDomainState =
4
+ | "Initial"
5
+ | "DomainSetupInProgress"
6
+ | "DomainSetupFailed"
7
+ | "DomainSetupSuccess"
8
+ | "SSLSetupInProgress"
9
+ | "SSLSetupFailed"
10
+ | "SSLSetupSuccess";
11
+
12
+ export const CustomDomain = z.object({
13
+ id: z.string(),
14
+ designSystemId: z.string(),
15
+ state: z.string(),
16
+
17
+ supernovaDomain: z.string(),
18
+ customerDomain: z.string().nullish(),
19
+
20
+ error: z.string().nullish(),
21
+ errorCode: z.string().nullish(),
22
+ });
23
+
24
+ export type CustomDomain = z.infer<typeof CustomDomain>;
@@ -0,0 +1 @@
1
+ export * from "./custom-domains";
@@ -0,0 +1 @@
1
+ export * from "./session";
@@ -0,0 +1,39 @@
1
+ import { z } from "zod";
2
+ import { User } from "../users";
3
+
4
+ export const NpmProxyToken = z.object({
5
+ access: z.string(),
6
+ expiresAt: z.number(),
7
+ });
8
+
9
+ export type NpmProxyToken = z.infer<typeof NpmProxyToken>;
10
+
11
+ export const SessionData = z.object({
12
+ returnToUrl: z.string().optional(),
13
+ npmProxyToken: NpmProxyToken.optional(),
14
+ });
15
+
16
+ export type SessionData = z.infer<typeof SessionData>;
17
+
18
+ export const Session = z.object({
19
+ id: z.string(),
20
+ expiresAt: z.date(),
21
+ userId: z.string().nullable(),
22
+ data: SessionData,
23
+ });
24
+
25
+ export type Session = z.infer<typeof Session>;
26
+
27
+ export const AuthTokens = z.object({
28
+ access: z.string(),
29
+ refresh: z.string(),
30
+ });
31
+
32
+ export type AuthTokens = z.infer<typeof AuthTokens>;
33
+
34
+ export const UserSession = z.object({
35
+ session: Session,
36
+ user: User.nullable(),
37
+ });
38
+
39
+ export type UserSession = z.infer<typeof UserSession>;
@@ -0,0 +1,18 @@
1
+ import { z } from "zod";
2
+ import { DbCreateInputOmit } from "../../helpers";
3
+
4
+ export const AssetReference = z.object({
5
+ id: z.string(),
6
+ designSystemVersionId: z.string(),
7
+ assetId: z.string(),
8
+ persistentId: z.string(),
9
+ });
10
+
11
+ export type AssetReference = z.infer<typeof AssetReference>;
12
+
13
+ export type CreateAssetReference = DbCreateInputOmit<AssetReference>;
14
+
15
+ export type AssetReferenceDiff = {
16
+ toCreate: CreateAssetReference[];
17
+ toDelete: string[];
18
+ };
@@ -0,0 +1,3 @@
1
+ import { z } from "zod";
2
+
3
+ export const AssetValue = z.object({});
@@ -0,0 +1,48 @@
1
+ import { z } from "zod";
2
+ import { OmitStrict } from "../../helpers";
3
+
4
+ export const AssetType = z.enum(["Image", "Font"]);
5
+ export const AssetScope = z.enum(["DocumentationFrame", "ComponentThumbnail", "DesignSystem", "Documentation"]);
6
+
7
+ export const AssetFontProperties = z.object({
8
+ family: z.string(),
9
+ subfamily: z.string(),
10
+ });
11
+
12
+ export const AssetProperties = z.object({
13
+ fontProperties: z.array(AssetFontProperties),
14
+ });
15
+
16
+ export const AssetOrigin = z.object({
17
+ originKey: z.string(),
18
+ });
19
+
20
+ export const Asset = z.object({
21
+ id: z.string(),
22
+ designSystemId: z.string().nullish(),
23
+ type: AssetType,
24
+ originalFileName: z.string().nullish(),
25
+ filePath: z.string(),
26
+ scope: AssetScope,
27
+ properties: AssetProperties.nullish(),
28
+ origin: AssetOrigin.nullish(),
29
+ });
30
+
31
+ export type AssetType = z.infer<typeof AssetType>;
32
+ export type AssetScope = z.infer<typeof AssetScope>;
33
+ export type AssetFontProperties = z.infer<typeof AssetFontProperties>;
34
+ export type AssetProperties = z.infer<typeof AssetProperties>;
35
+ export type AssetOrigin = z.infer<typeof AssetOrigin>;
36
+ export type Asset = z.infer<typeof Asset>;
37
+
38
+ export type ImportedAsset = OmitStrict<Asset, "origin"> & {
39
+ origin: AssetOrigin;
40
+ };
41
+
42
+ export type ResolvedAsset = OmitStrict<Asset, "filePath"> & {
43
+ url: string;
44
+ };
45
+
46
+ export function isImportedAsset(asset: Asset): asset is ImportedAsset {
47
+ return !!asset.origin;
48
+ }
@@ -0,0 +1,3 @@
1
+ export * from "./asset-reference";
2
+ export * from "./asset-value";
3
+ export * from "./asset";