@budibase/types 2.12.1 → 2.12.2

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.
@@ -0,0 +1,8 @@
1
+ export interface Upload {
2
+ size: number;
3
+ name: string;
4
+ url: string;
5
+ extension: string;
6
+ key: string;
7
+ }
8
+ export type ProcessAttachmentResponse = Upload[];
@@ -16,3 +16,7 @@ export interface CreateAppBackupResponse {
16
16
  export interface UpdateAppBackupRequest {
17
17
  name: string;
18
18
  }
19
+ export interface ImportAppBackupResponse {
20
+ restoreId: string;
21
+ message: string;
22
+ }
@@ -5,3 +5,4 @@ export * from "./view";
5
5
  export * from "./rows";
6
6
  export * from "./table";
7
7
  export * from "./permission";
8
+ export * from "./attachment";
@@ -1,4 +1,4 @@
1
- import { Row, Table, TableRequest, TableSchema, View, ViewV2 } from "../../../documents";
1
+ import { FieldSchema, Row, Table, TableRequest, TableSchema, View, ViewV2 } from "../../../documents";
2
2
  interface ViewV2Response extends ViewV2 {
3
3
  schema: TableSchema;
4
4
  }
@@ -20,4 +20,11 @@ export interface BulkImportRequest {
20
20
  export interface BulkImportResponse {
21
21
  message: string;
22
22
  }
23
+ export interface MigrateRequest {
24
+ oldColumn: FieldSchema;
25
+ newColumn: FieldSchema;
26
+ }
27
+ export interface MigrateResponse {
28
+ message: string;
29
+ }
23
30
  export {};
@@ -107,4 +107,9 @@ export type FieldSchema = OtherFieldMetadata | DateFieldMetadata | RelationshipF
107
107
  export interface TableSchema {
108
108
  [key: string]: FieldSchema;
109
109
  }
110
+ export declare function isRelationshipField(field: FieldSchema): field is RelationshipFieldMetadata;
111
+ export declare function isManyToMany(field: RelationshipFieldMetadata): field is ManyToManyRelationshipFieldMetadata;
112
+ export declare function isOneToMany(field: RelationshipFieldMetadata): field is OneToManyRelationshipFieldMetadata;
113
+ export declare function isManyToOne(field: RelationshipFieldMetadata): field is ManyToOneRelationshipFieldMetadata;
114
+ export declare function isBBReferenceField(field: FieldSchema): field is BBReferenceFieldMetadata;
110
115
  export {};
@@ -2,16 +2,22 @@ import { Document } from "../../document";
2
2
  import { View, ViewV2 } from "../view";
3
3
  import { RenameColumn } from "../../../sdk";
4
4
  import { TableSchema } from "./schema";
5
+ export declare const INTERNAL_TABLE_SOURCE_ID = "bb_internal";
6
+ export declare enum TableSourceType {
7
+ EXTERNAL = "external",
8
+ INTERNAL = "internal"
9
+ }
5
10
  export interface Table extends Document {
6
- type?: string;
11
+ type: "table";
12
+ sourceType: TableSourceType;
7
13
  views?: {
8
14
  [key: string]: View | ViewV2;
9
15
  };
10
16
  name: string;
17
+ sourceId: string;
11
18
  primary?: string[];
12
19
  schema: TableSchema;
13
20
  primaryDisplay?: string;
14
- sourceId?: string;
15
21
  relatedFormula?: string[];
16
22
  constrained?: string[];
17
23
  sql?: boolean;
@@ -21,9 +27,6 @@ export interface Table extends Document {
21
27
  created?: boolean;
22
28
  rowHeight?: number;
23
29
  }
24
- export interface ExternalTable extends Table {
25
- sourceId: string;
26
- }
27
30
  export interface TableRequest extends Table {
28
31
  _rename?: RenameColumn;
29
32
  created?: boolean;
package/dist/index.js CHANGED
@@ -65,6 +65,7 @@ __export(src_exports, {
65
65
  FormulaTypes: () => FormulaTypes,
66
66
  GroupType: () => GroupType,
67
67
  Hosting: () => Hosting,
68
+ INTERNAL_TABLE_SOURCE_ID: () => INTERNAL_TABLE_SOURCE_ID,
68
69
  IdentityType: () => IdentityType,
69
70
  IncludeRelationship: () => IncludeRelationship,
70
71
  InitType: () => InitType,
@@ -104,6 +105,7 @@ __export(src_exports, {
104
105
  SortType: () => SortType,
105
106
  SourceName: () => SourceName,
106
107
  StaticQuotaName: () => StaticQuotaName,
108
+ TableSourceType: () => TableSourceType,
107
109
  TenantResolutionStrategy: () => TenantResolutionStrategy,
108
110
  UNICODE_MAX: () => UNICODE_MAX,
109
111
  UserGroupSyncEvents: () => UserGroupSyncEvents,
@@ -112,14 +114,19 @@ __export(src_exports, {
112
114
  VirtualDocumentType: () => VirtualDocumentType,
113
115
  WebhookActionType: () => WebhookActionType,
114
116
  isAppBackupMetadata: () => isAppBackupMetadata,
117
+ isBBReferenceField: () => isBBReferenceField,
115
118
  isCloudAccount: () => isCloudAccount,
116
119
  isConstantQuota: () => isConstantQuota,
117
120
  isCreatePasswordAccount: () => isCreatePasswordAccount,
118
121
  isDocument: () => isDocument,
119
122
  isGoogleConfig: () => isGoogleConfig,
123
+ isManyToMany: () => isManyToMany,
124
+ isManyToOne: () => isManyToOne,
120
125
  isMonthlyQuota: () => isMonthlyQuota,
121
126
  isOIDCConfig: () => isOIDCConfig,
127
+ isOneToMany: () => isOneToMany,
122
128
  isPasswordAccount: () => isPasswordAccount,
129
+ isRelationshipField: () => isRelationshipField,
123
130
  isSCIMConfig: () => isSCIMConfig,
124
131
  isSMTPConfig: () => isSMTPConfig,
125
132
  isSSOAccount: () => isSSOAccount,
@@ -866,6 +873,46 @@ var RestAuthType = /* @__PURE__ */ ((RestAuthType2) => {
866
873
  return RestAuthType2;
867
874
  })(RestAuthType || {});
868
875
 
876
+ // src/documents/app/table/table.ts
877
+ var INTERNAL_TABLE_SOURCE_ID = "bb_internal";
878
+ var TableSourceType = /* @__PURE__ */ ((TableSourceType2) => {
879
+ TableSourceType2["EXTERNAL"] = "external";
880
+ TableSourceType2["INTERNAL"] = "internal";
881
+ return TableSourceType2;
882
+ })(TableSourceType || {});
883
+
884
+ // src/documents/app/row.ts
885
+ var FieldType = /* @__PURE__ */ ((FieldType2) => {
886
+ FieldType2["STRING"] = "string";
887
+ FieldType2["LONGFORM"] = "longform";
888
+ FieldType2["OPTIONS"] = "options";
889
+ FieldType2["NUMBER"] = "number";
890
+ FieldType2["BOOLEAN"] = "boolean";
891
+ FieldType2["ARRAY"] = "array";
892
+ FieldType2["DATETIME"] = "datetime";
893
+ FieldType2["ATTACHMENT"] = "attachment";
894
+ FieldType2["LINK"] = "link";
895
+ FieldType2["FORMULA"] = "formula";
896
+ FieldType2["AUTO"] = "auto";
897
+ FieldType2["JSON"] = "json";
898
+ FieldType2["INTERNAL"] = "internal";
899
+ FieldType2["BARCODEQR"] = "barcodeqr";
900
+ FieldType2["BIGINT"] = "bigint";
901
+ FieldType2["BB_REFERENCE"] = "bb_reference";
902
+ return FieldType2;
903
+ })(FieldType || {});
904
+ var FieldSubtype = /* @__PURE__ */ ((FieldSubtype3) => {
905
+ FieldSubtype3["USER"] = "user";
906
+ FieldSubtype3["USERS"] = "users";
907
+ return FieldSubtype3;
908
+ })(FieldSubtype || {});
909
+ var FieldTypeSubtypes = {
910
+ BB_REFERENCE: {
911
+ USER: "user" /* USER */,
912
+ USERS: "users" /* USERS */
913
+ }
914
+ };
915
+
869
916
  // src/documents/app/table/constants.ts
870
917
  var RelationshipType = /* @__PURE__ */ ((RelationshipType2) => {
871
918
  RelationshipType2["ONE_TO_MANY"] = "one-to-many";
@@ -873,24 +920,41 @@ var RelationshipType = /* @__PURE__ */ ((RelationshipType2) => {
873
920
  RelationshipType2["MANY_TO_MANY"] = "many-to-many";
874
921
  return RelationshipType2;
875
922
  })(RelationshipType || {});
876
- var AutoReason = /* @__PURE__ */ ((AutoReason2) => {
877
- AutoReason2["FOREIGN_KEY"] = "foreign_key";
878
- return AutoReason2;
923
+ var AutoReason = /* @__PURE__ */ ((AutoReason3) => {
924
+ AutoReason3["FOREIGN_KEY"] = "foreign_key";
925
+ return AutoReason3;
879
926
  })(AutoReason || {});
880
- var AutoFieldSubTypes = /* @__PURE__ */ ((AutoFieldSubTypes2) => {
881
- AutoFieldSubTypes2["CREATED_BY"] = "createdBy";
882
- AutoFieldSubTypes2["CREATED_AT"] = "createdAt";
883
- AutoFieldSubTypes2["UPDATED_BY"] = "updatedBy";
884
- AutoFieldSubTypes2["UPDATED_AT"] = "updatedAt";
885
- AutoFieldSubTypes2["AUTO_ID"] = "autoID";
886
- return AutoFieldSubTypes2;
927
+ var AutoFieldSubTypes = /* @__PURE__ */ ((AutoFieldSubTypes3) => {
928
+ AutoFieldSubTypes3["CREATED_BY"] = "createdBy";
929
+ AutoFieldSubTypes3["CREATED_AT"] = "createdAt";
930
+ AutoFieldSubTypes3["UPDATED_BY"] = "updatedBy";
931
+ AutoFieldSubTypes3["UPDATED_AT"] = "updatedAt";
932
+ AutoFieldSubTypes3["AUTO_ID"] = "autoID";
933
+ return AutoFieldSubTypes3;
887
934
  })(AutoFieldSubTypes || {});
888
- var FormulaTypes = /* @__PURE__ */ ((FormulaTypes2) => {
889
- FormulaTypes2["STATIC"] = "static";
890
- FormulaTypes2["DYNAMIC"] = "dynamic";
891
- return FormulaTypes2;
935
+ var FormulaTypes = /* @__PURE__ */ ((FormulaTypes3) => {
936
+ FormulaTypes3["STATIC"] = "static";
937
+ FormulaTypes3["DYNAMIC"] = "dynamic";
938
+ return FormulaTypes3;
892
939
  })(FormulaTypes || {});
893
940
 
941
+ // src/documents/app/table/schema.ts
942
+ function isRelationshipField(field) {
943
+ return field.type === "link" /* LINK */;
944
+ }
945
+ function isManyToMany(field) {
946
+ return field.relationshipType === "many-to-many" /* MANY_TO_MANY */;
947
+ }
948
+ function isOneToMany(field) {
949
+ return field.relationshipType === "one-to-many" /* ONE_TO_MANY */;
950
+ }
951
+ function isManyToOne(field) {
952
+ return field.relationshipType === "many-to-one" /* MANY_TO_ONE */;
953
+ }
954
+ function isBBReferenceField(field) {
955
+ return field.type === "bb_reference" /* BB_REFERENCE */;
956
+ }
957
+
894
958
  // src/documents/app/view.ts
895
959
  var ViewCalculation = /* @__PURE__ */ ((ViewCalculation2) => {
896
960
  ViewCalculation2["SUM"] = "sum";
@@ -963,38 +1027,6 @@ var VirtualDocumentType = /* @__PURE__ */ ((VirtualDocumentType2) => {
963
1027
  return VirtualDocumentType2;
964
1028
  })(VirtualDocumentType || {});
965
1029
 
966
- // src/documents/app/row.ts
967
- var FieldType = /* @__PURE__ */ ((FieldType2) => {
968
- FieldType2["STRING"] = "string";
969
- FieldType2["LONGFORM"] = "longform";
970
- FieldType2["OPTIONS"] = "options";
971
- FieldType2["NUMBER"] = "number";
972
- FieldType2["BOOLEAN"] = "boolean";
973
- FieldType2["ARRAY"] = "array";
974
- FieldType2["DATETIME"] = "datetime";
975
- FieldType2["ATTACHMENT"] = "attachment";
976
- FieldType2["LINK"] = "link";
977
- FieldType2["FORMULA"] = "formula";
978
- FieldType2["AUTO"] = "auto";
979
- FieldType2["JSON"] = "json";
980
- FieldType2["INTERNAL"] = "internal";
981
- FieldType2["BARCODEQR"] = "barcodeqr";
982
- FieldType2["BIGINT"] = "bigint";
983
- FieldType2["BB_REFERENCE"] = "bb_reference";
984
- return FieldType2;
985
- })(FieldType || {});
986
- var FieldSubtype = /* @__PURE__ */ ((FieldSubtype2) => {
987
- FieldSubtype2["USER"] = "user";
988
- FieldSubtype2["USERS"] = "users";
989
- return FieldSubtype2;
990
- })(FieldSubtype || {});
991
- var FieldTypeSubtypes = {
992
- BB_REFERENCE: {
993
- USER: "user" /* USER */,
994
- USERS: "users" /* USERS */
995
- }
996
- };
997
-
998
1030
  // src/documents/app/backup.ts
999
1031
  var AppBackupType = /* @__PURE__ */ ((AppBackupType2) => {
1000
1032
  AppBackupType2["BACKUP"] = "backup";
@@ -1208,6 +1240,7 @@ var ServiceType = /* @__PURE__ */ ((ServiceType2) => {
1208
1240
  FormulaTypes,
1209
1241
  GroupType,
1210
1242
  Hosting,
1243
+ INTERNAL_TABLE_SOURCE_ID,
1211
1244
  IdentityType,
1212
1245
  IncludeRelationship,
1213
1246
  InitType,
@@ -1247,6 +1280,7 @@ var ServiceType = /* @__PURE__ */ ((ServiceType2) => {
1247
1280
  SortType,
1248
1281
  SourceName,
1249
1282
  StaticQuotaName,
1283
+ TableSourceType,
1250
1284
  TenantResolutionStrategy,
1251
1285
  UNICODE_MAX,
1252
1286
  UserGroupSyncEvents,
@@ -1255,14 +1289,19 @@ var ServiceType = /* @__PURE__ */ ((ServiceType2) => {
1255
1289
  VirtualDocumentType,
1256
1290
  WebhookActionType,
1257
1291
  isAppBackupMetadata,
1292
+ isBBReferenceField,
1258
1293
  isCloudAccount,
1259
1294
  isConstantQuota,
1260
1295
  isCreatePasswordAccount,
1261
1296
  isDocument,
1262
1297
  isGoogleConfig,
1298
+ isManyToMany,
1299
+ isManyToOne,
1263
1300
  isMonthlyQuota,
1264
1301
  isOIDCConfig,
1302
+ isOneToMany,
1265
1303
  isPasswordAccount,
1304
+ isRelationshipField,
1266
1305
  isSCIMConfig,
1267
1306
  isSMTPConfig,
1268
1307
  isSSOAccount,