@onetype/framework 2.0.51 → 2.0.53
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.
|
@@ -38,7 +38,7 @@ onetype.AddonReady('commands', (commands) =>
|
|
|
38
38
|
|
|
39
39
|
const item = addon.Item(properties.data);
|
|
40
40
|
|
|
41
|
-
const allowed = expose.create.call({http: this.http, properties, item});
|
|
41
|
+
const allowed = await expose.create.call({http: this.http, properties, item});
|
|
42
42
|
|
|
43
43
|
if(allowed !== true)
|
|
44
44
|
{
|
|
@@ -35,19 +35,19 @@ onetype.AddonReady('commands', (commands) =>
|
|
|
35
35
|
return resolve(null, 'Delete is not allowed.', 403);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
if(!properties.
|
|
38
|
+
if(!properties.id || (typeof properties.id !== 'string' && typeof properties.id !== 'number'))
|
|
39
39
|
{
|
|
40
40
|
return resolve(null, 'Invalid or missing id.', 400);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
const item = await addon.Find().filter('id', properties.
|
|
43
|
+
const item = await addon.Find().filter('id', properties.id).one(true);
|
|
44
44
|
|
|
45
45
|
if(!item)
|
|
46
46
|
{
|
|
47
47
|
return resolve(null, 'Item not found.', 404);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
const allowed = expose.delete.call({http: this.http, properties, item});
|
|
50
|
+
const allowed = await expose.delete.call({http: this.http, properties, item});
|
|
51
51
|
|
|
52
52
|
if(allowed !== true)
|
|
53
53
|
{
|
|
@@ -54,7 +54,7 @@ onetype.AddonReady('commands', (commands) =>
|
|
|
54
54
|
item.Set(key, value);
|
|
55
55
|
});
|
|
56
56
|
|
|
57
|
-
const allowed = expose.update.call({http: this.http, properties, item});
|
|
57
|
+
const allowed = await expose.update.call({http: this.http, properties, item});
|
|
58
58
|
|
|
59
59
|
if(allowed !== true)
|
|
60
60
|
{
|
|
@@ -59,8 +59,9 @@ onetype.AddonReady('directives', function(directives)
|
|
|
59
59
|
if(!compile.data[config.bind])
|
|
60
60
|
{
|
|
61
61
|
compile.data[config.bind] = {
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
data: null,
|
|
63
|
+
message: null,
|
|
64
|
+
code: null,
|
|
64
65
|
loading: false
|
|
65
66
|
};
|
|
66
67
|
}
|
|
@@ -127,7 +128,7 @@ onetype.AddonReady('directives', function(directives)
|
|
|
127
128
|
|
|
128
129
|
if(!config.endpoint)
|
|
129
130
|
{
|
|
130
|
-
state.
|
|
131
|
+
state.data = submitData;
|
|
131
132
|
config.onSuccess && await config.onSuccess(submitData);
|
|
132
133
|
config.reset && form.reset();
|
|
133
134
|
compile.data.Update();
|
|
@@ -135,7 +136,8 @@ onetype.AddonReady('directives', function(directives)
|
|
|
135
136
|
}
|
|
136
137
|
|
|
137
138
|
state.loading = true;
|
|
138
|
-
state.
|
|
139
|
+
state.message = null;
|
|
140
|
+
state.code = null;
|
|
139
141
|
compile.data.Update();
|
|
140
142
|
|
|
141
143
|
try
|
|
@@ -148,17 +150,20 @@ onetype.AddonReady('directives', function(directives)
|
|
|
148
150
|
body: JSON.stringify(submitData)
|
|
149
151
|
});
|
|
150
152
|
|
|
151
|
-
if(!response.ok)
|
|
152
|
-
{
|
|
153
|
-
throw onetype.Error(response.status, 'HTTP :status:.', { status: response.status });
|
|
154
|
-
}
|
|
155
|
-
|
|
156
153
|
const result = await response.json();
|
|
157
154
|
|
|
158
|
-
state.
|
|
159
|
-
state.
|
|
155
|
+
state.data = result.data || null;
|
|
156
|
+
state.message = result.message || null;
|
|
157
|
+
state.code = result.code || response.status;
|
|
160
158
|
state.loading = false;
|
|
161
159
|
|
|
160
|
+
if(!response.ok)
|
|
161
|
+
{
|
|
162
|
+
config.onError && config.onError(state);
|
|
163
|
+
compile.data.Update();
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
|
|
162
167
|
config.reset && form.reset();
|
|
163
168
|
|
|
164
169
|
if(config.redirect)
|
|
@@ -171,8 +176,9 @@ onetype.AddonReady('directives', function(directives)
|
|
|
171
176
|
}
|
|
172
177
|
catch(error)
|
|
173
178
|
{
|
|
174
|
-
state.
|
|
175
|
-
state.
|
|
179
|
+
state.data = null;
|
|
180
|
+
state.message = error.message;
|
|
181
|
+
state.code = 0;
|
|
176
182
|
state.loading = false;
|
|
177
183
|
|
|
178
184
|
config.onError && config.onError(state);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onetype/framework",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.53",
|
|
4
4
|
"description": "OneType Framework — Full-stack isomorphic JavaScript framework built from scratch. One addon abstraction powers databases, servers, commands, pages, directives, queues, and more.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/load.js",
|