@basictech/react 0.2.0-beta.7 → 0.2.0-beta.9

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.
@@ -1,6 +1,6 @@
1
1
 
2
2
  
3
- > @basictech/react@0.2.0-beta.3 build
3
+ > @basictech/react@0.2.0-beta.7 build
4
4
  > tsup
5
5
 
6
6
  CLI Building entry: src/index.ts
@@ -11,13 +11,13 @@
11
11
  CLI Cleaning output folder
12
12
  CJS Build start
13
13
  ESM Build start
14
- ESM dist/index.mjs 19.59 KB
15
- ESM dist/index.mjs.map 43.63 KB
16
- ESM ⚡️ Build success in 20ms
17
- CJS dist/index.js 21.81 KB
18
- CJS dist/index.js.map 43.69 KB
19
- CJS ⚡️ Build success in 20ms
14
+ CJS dist/index.js 22.22 KB
15
+ CJS dist/index.js.map 45.33 KB
16
+ CJS ⚡️ Build success in 14ms
17
+ ESM dist/index.mjs 19.99 KB
18
+ ESM dist/index.mjs.map 45.28 KB
19
+ ESM ⚡️ Build success in 14ms
20
20
  DTS Build start
21
- DTS ⚡️ Build success in 997ms
22
- DTS dist/index.d.ts 975.00 B
23
- DTS dist/index.d.mts 975.00 B
21
+ DTS ⚡️ Build success in 934ms
22
+ DTS dist/index.d.ts 1003.00 B
23
+ DTS dist/index.d.mts 1003.00 B
package/changelog.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # 1.3.4
2
2
 
3
+ ## 0.2.0-beta.9
4
+
5
+ ### Minor Changes
6
+
7
+ - add schema validation
8
+
9
+ ## 0.2.0-beta.8
10
+
11
+ ### Minor Changes
12
+
13
+ - changed isLoaded to isAuthReady and fixed dbStatus hooks for useBasic
14
+
3
15
  ## 0.2.0-beta.7
4
16
 
5
17
  ### Minor Changes
package/dist/index.d.mts CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import React from 'react';
3
+ import { ErrorObject } from 'ajv';
3
4
 
4
5
  declare enum DBStatus {
5
6
  LOADING = "LOADING",
@@ -26,7 +27,7 @@ declare function BasicProvider({ children, project_id, schema, debug }: {
26
27
  }): react_jsx_runtime.JSX.Element;
27
28
  declare function useBasic(): {
28
29
  unicorn: string;
29
- isLoaded: boolean;
30
+ isAuthReady: boolean;
30
31
  isSignedIn: boolean;
31
32
  user: User | null;
32
33
  signout: () => void;
@@ -37,6 +38,97 @@ declare function useBasic(): {
37
38
  dbStatus: DBStatus;
38
39
  };
39
40
 
41
+ declare const basicJsonSchema: {
42
+ $schema: string;
43
+ type: string;
44
+ properties: {
45
+ project_id: {
46
+ type: string;
47
+ };
48
+ namespace: {
49
+ type: string;
50
+ };
51
+ version: {
52
+ type: string;
53
+ minimum: number;
54
+ };
55
+ tables: {
56
+ type: string;
57
+ patternProperties: {
58
+ "^[a-zA-Z0-9_]+$": {
59
+ type: string;
60
+ properties: {
61
+ name: {
62
+ type: string;
63
+ };
64
+ type: {
65
+ type: string;
66
+ enum: string[];
67
+ };
68
+ fields: {
69
+ type: string;
70
+ patternProperties: {
71
+ "^[a-zA-Z0-9_]+$": {
72
+ type: string;
73
+ properties: {
74
+ type: {
75
+ type: string;
76
+ enum: string[];
77
+ };
78
+ indexed: {
79
+ type: string;
80
+ };
81
+ required: {
82
+ type: string;
83
+ };
84
+ };
85
+ required: string[];
86
+ };
87
+ };
88
+ additionalProperties: boolean;
89
+ };
90
+ };
91
+ required: string[];
92
+ };
93
+ };
94
+ additionalProperties: boolean;
95
+ };
96
+ };
97
+ required: string[];
98
+ };
99
+ type Schema = typeof basicJsonSchema;
100
+ declare function generateEmptySchema(): void;
101
+ /**
102
+ * Validate a schema
103
+ * only checks if the schema is formatted correctly, not if can be published
104
+ * @param schema - The schema to validate
105
+ * @returns {valid: boolean, errors: any[]} - The validation result
106
+ */
107
+ declare function validateSchema(schema: Schema): {
108
+ valid: boolean;
109
+ errors: ErrorObject[];
110
+ };
111
+ declare function validateData(schema: any, table: string, data: Record<string, any>, checkRequired?: boolean): {
112
+ valid: boolean;
113
+ errors: ErrorObject<string, Record<string, any>, unknown>[];
114
+ message: string;
115
+ } | {
116
+ valid: boolean;
117
+ errors: {
118
+ message: string;
119
+ }[];
120
+ message: string;
121
+ } | {
122
+ valid: boolean;
123
+ errors: never[];
124
+ message?: undefined;
125
+ };
126
+
40
127
  declare function useQuery(queryable: any): any;
128
+ declare const sc: {
129
+ validateSchema: typeof validateSchema;
130
+ validateData: typeof validateData;
131
+ generateEmptySchema: typeof generateEmptySchema;
132
+ };
41
133
 
42
- export { BasicProvider, useBasic, useQuery };
134
+ export { BasicProvider, sc, useBasic, useQuery };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import React from 'react';
3
+ import { ErrorObject } from 'ajv';
3
4
 
4
5
  declare enum DBStatus {
5
6
  LOADING = "LOADING",
@@ -26,7 +27,7 @@ declare function BasicProvider({ children, project_id, schema, debug }: {
26
27
  }): react_jsx_runtime.JSX.Element;
27
28
  declare function useBasic(): {
28
29
  unicorn: string;
29
- isLoaded: boolean;
30
+ isAuthReady: boolean;
30
31
  isSignedIn: boolean;
31
32
  user: User | null;
32
33
  signout: () => void;
@@ -37,6 +38,97 @@ declare function useBasic(): {
37
38
  dbStatus: DBStatus;
38
39
  };
39
40
 
41
+ declare const basicJsonSchema: {
42
+ $schema: string;
43
+ type: string;
44
+ properties: {
45
+ project_id: {
46
+ type: string;
47
+ };
48
+ namespace: {
49
+ type: string;
50
+ };
51
+ version: {
52
+ type: string;
53
+ minimum: number;
54
+ };
55
+ tables: {
56
+ type: string;
57
+ patternProperties: {
58
+ "^[a-zA-Z0-9_]+$": {
59
+ type: string;
60
+ properties: {
61
+ name: {
62
+ type: string;
63
+ };
64
+ type: {
65
+ type: string;
66
+ enum: string[];
67
+ };
68
+ fields: {
69
+ type: string;
70
+ patternProperties: {
71
+ "^[a-zA-Z0-9_]+$": {
72
+ type: string;
73
+ properties: {
74
+ type: {
75
+ type: string;
76
+ enum: string[];
77
+ };
78
+ indexed: {
79
+ type: string;
80
+ };
81
+ required: {
82
+ type: string;
83
+ };
84
+ };
85
+ required: string[];
86
+ };
87
+ };
88
+ additionalProperties: boolean;
89
+ };
90
+ };
91
+ required: string[];
92
+ };
93
+ };
94
+ additionalProperties: boolean;
95
+ };
96
+ };
97
+ required: string[];
98
+ };
99
+ type Schema = typeof basicJsonSchema;
100
+ declare function generateEmptySchema(): void;
101
+ /**
102
+ * Validate a schema
103
+ * only checks if the schema is formatted correctly, not if can be published
104
+ * @param schema - The schema to validate
105
+ * @returns {valid: boolean, errors: any[]} - The validation result
106
+ */
107
+ declare function validateSchema(schema: Schema): {
108
+ valid: boolean;
109
+ errors: ErrorObject[];
110
+ };
111
+ declare function validateData(schema: any, table: string, data: Record<string, any>, checkRequired?: boolean): {
112
+ valid: boolean;
113
+ errors: ErrorObject<string, Record<string, any>, unknown>[];
114
+ message: string;
115
+ } | {
116
+ valid: boolean;
117
+ errors: {
118
+ message: string;
119
+ }[];
120
+ message: string;
121
+ } | {
122
+ valid: boolean;
123
+ errors: never[];
124
+ message?: undefined;
125
+ };
126
+
40
127
  declare function useQuery(queryable: any): any;
128
+ declare const sc: {
129
+ validateSchema: typeof validateSchema;
130
+ validateData: typeof validateData;
131
+ generateEmptySchema: typeof generateEmptySchema;
132
+ };
41
133
 
42
- export { BasicProvider, useBasic, useQuery };
134
+ export { BasicProvider, sc, useBasic, useQuery };