@akanjs/store 1.0.5 → 1.0.7-canary.0

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.
@@ -66,7 +66,7 @@ const createDatabaseState = (refName) => {
66
66
  const baseState = {
67
67
  [names.model]: null,
68
68
  [names.modelLoading]: true,
69
- [names.modelForm]: cnst.getDefault(),
69
+ [names.modelForm]: new cnst.input(),
70
70
  [names.modelFormLoading]: true,
71
71
  [names.modelSubmit]: { disabled: true, loading: false, times: 0 },
72
72
  [names.modelViewAt]: /* @__PURE__ */ new Date(0),
@@ -113,13 +113,13 @@ const createSliceState = (refName, slices) => {
113
113
  sortOfModel: SliceName.replace(names.Model, names.sortOfModel)
114
114
  };
115
115
  const singleSliceState = {
116
- [namesOfSlice.defaultModel]: cnst.getDefault(),
116
+ [namesOfSlice.defaultModel]: new cnst.full(),
117
117
  [namesOfSlice.modelList]: new import_base.DataList(),
118
118
  [namesOfSlice.modelListLoading]: true,
119
119
  [namesOfSlice.modelInitList]: new import_base.DataList(),
120
120
  [namesOfSlice.modelInitAt]: /* @__PURE__ */ new Date(0),
121
121
  [namesOfSlice.modelSelection]: new import_base.DataList(),
122
- [namesOfSlice.modelInsight]: cnst.getDefaultInsight(),
122
+ [namesOfSlice.modelInsight]: new cnst.insight(),
123
123
  [namesOfSlice.lastPageOfModel]: 1,
124
124
  [namesOfSlice.pageOfModel]: 1,
125
125
  [namesOfSlice.limitOfModel]: 20,
@@ -133,7 +133,6 @@ const createSliceState = (refName, slices) => {
133
133
  const makeFormSetter = (refName) => {
134
134
  const [fieldName, className] = [refName, (0, import_common.capitalize)(refName)];
135
135
  const modelRef = import_constant.constantInfo.getDatabase(refName).full;
136
- const fieldMetas = (0, import_constant.getFieldMetas)(modelRef);
137
136
  const names = {
138
137
  model: fieldName,
139
138
  Model: className,
@@ -148,8 +147,8 @@ const makeFormSetter = (refName) => {
148
147
  });
149
148
  }
150
149
  };
151
- const fieldSetAction = fieldMetas.reduce((acc, fieldMeta) => {
152
- const [fieldKeyName, classKeyName] = [(0, import_common.lowerlize)(fieldMeta.key), (0, import_common.capitalize)(fieldMeta.key)];
150
+ const fieldSetAction = Object.entries(modelRef.field).reduce((acc, [key, field]) => {
151
+ const [fieldKeyName, classKeyName] = [(0, import_common.lowerlize)(key), (0, import_common.capitalize)(key)];
153
152
  const namesOfField = {
154
153
  field: fieldKeyName,
155
154
  Field: classKeyName,
@@ -162,18 +161,18 @@ const makeFormSetter = (refName) => {
162
161
  const singleFieldSetAction = {
163
162
  [namesOfField.setFieldOnModel]: function(value) {
164
163
  this.set((state) => {
165
- const setValue = fieldMeta.isClass ? (0, import_signal.immerify)(fieldMeta.modelRef, value) : value;
164
+ const setValue = field.isClass ? (0, import_signal.immerify)(field.modelRef, value) : value;
166
165
  state[names.modelForm][namesOfField.field] = setValue;
167
166
  });
168
167
  },
169
- ...fieldMeta.isArray ? {
168
+ ...field.isArray ? {
170
169
  [namesOfField.addFieldOnModel]: function(value, options = {}) {
171
170
  const form = this.get()[names.modelForm];
172
171
  const length = form[namesOfField.field].length;
173
172
  if (options.limit && options.limit <= length)
174
173
  return;
175
174
  const idx = options.idx ?? length;
176
- const setValue = fieldMeta.isClass ? (0, import_signal.immerify)(fieldMeta.modelRef, value) : value;
175
+ const setValue = field.isClass ? (0, import_signal.immerify)(field.modelRef, value) : value;
177
176
  this.set((state) => {
178
177
  state[names.modelForm][namesOfField.field] = [
179
178
  ...form[namesOfField.field].slice(0, idx),
@@ -197,7 +196,7 @@ const makeFormSetter = (refName) => {
197
196
  this[namesOfField.subFieldOnModel](index);
198
197
  }
199
198
  } : {},
200
- ...fieldMeta.isClass && import_constant.constantInfo.getRefName(fieldMeta.modelRef) === "file" ? {
199
+ ...field.isClass && import_constant.constantInfo.getRefName(field.modelRef) === "file" ? {
201
200
  [namesOfField.uploadFieldOnModel]: async function(fileList, index) {
202
201
  const form = this.get()[names.modelForm];
203
202
  if (!fileList.length)
@@ -206,7 +205,7 @@ const makeFormSetter = (refName) => {
206
205
  fileList,
207
206
  form.id
208
207
  );
209
- if (fieldMeta.isArray) {
208
+ if (field.isArray) {
210
209
  const idx = index ?? form[namesOfField.field].length;
211
210
  this.set((state) => {
212
211
  state[names.modelForm][namesOfField.field] = [
@@ -224,7 +223,7 @@ const makeFormSetter = (refName) => {
224
223
  const intervalKey = setInterval(() => {
225
224
  void (async () => {
226
225
  const currentFile = await fetch.file(file.id);
227
- if (fieldMeta.isArray)
226
+ if (field.isArray)
228
227
  this.set((state) => {
229
228
  state[names.modelForm][namesOfField.field] = state[names.modelForm][namesOfField.field].map(
230
229
  (file2) => file2.id === currentFile.id ? currentFile : file2
@@ -310,13 +309,13 @@ const makeActions = (refName, slices) => {
310
309
  const modelListLoading = currentState[namesOfSlice.modelListLoading];
311
310
  const modelInsight = currentState[namesOfSlice.modelInsight];
312
311
  const defaultModel = currentState[namesOfSlice.defaultModel];
313
- const modelInput = cnst.purify(modelForm);
312
+ const modelInput = cnst.input.purify(modelForm);
314
313
  if (!modelInput)
315
314
  return;
316
315
  this.set({ [names.modelLoading]: true });
317
316
  const model = await fetch[names.createModel](modelInput, { onError });
318
317
  const newModelList = modelListLoading ? modelList : new import_base.DataList([...modelList.slice(0, idx ?? 0), model, ...modelList.slice(idx ?? 0)]);
319
- const newModelInsight = cnst.crystalizeInsight({
318
+ const newModelInsight = new cnst.insight().set({
320
319
  ...modelInsight,
321
320
  count: modelInsight.count + 1
322
321
  });
@@ -341,7 +340,7 @@ const makeActions = (refName, slices) => {
341
340
  const model = currentState[names.model];
342
341
  const modelForm = currentState[names.modelForm];
343
342
  const defaultModel = currentState[namesOfSlice.defaultModel];
344
- const modelInput = cnst.purify(modelForm);
343
+ const modelInput = cnst.input.purify(modelForm);
345
344
  if (!modelInput)
346
345
  return;
347
346
  if (model?.id === modelForm.id)
@@ -355,7 +354,7 @@ const makeActions = (refName, slices) => {
355
354
  [names.modelModal]: modal ?? null,
356
355
  ...typeof path === "string" && path ? { [path]: updatedModel } : {}
357
356
  });
358
- const updatedLightModel = cnst.lightCrystalize(updatedModel);
357
+ const updatedLightModel = new cnst.light().set(updatedModel);
359
358
  slices.forEach(({ sliceName: sliceName2 }) => {
360
359
  const namesOfSlice2 = {
361
360
  modelList: sliceName2.replace(names.model, names.modelList),
@@ -383,13 +382,13 @@ const makeActions = (refName, slices) => {
383
382
  const modelList = currentState[namesOfSlice.modelList];
384
383
  const modelListLoading = currentState[namesOfSlice.modelListLoading];
385
384
  const modelInsight = currentState[namesOfSlice.modelInsight];
386
- const modelInput = cnst.purify(data);
385
+ const modelInput = cnst.input.purify(data);
387
386
  if (!modelInput)
388
387
  return;
389
388
  this.set({ [names.modelLoading]: true });
390
389
  const model = await fetch[names.createModel](modelInput, { onError });
391
390
  const newModelList = modelListLoading ? modelList : new import_base.DataList([...modelList.slice(0, idx ?? 0), model, ...modelList.slice(idx ?? 0)]);
392
- const newModelInsight = cnst.crystalizeInsight({
391
+ const newModelInsight = new cnst.insight().set({
393
392
  ...modelInsight,
394
393
  count: modelInsight.count + 1
395
394
  });
@@ -407,7 +406,7 @@ const makeActions = (refName, slices) => {
407
406
  [names.updateModel]: async function(id, data, { idx, path, modal, sliceName = names.model, onError, onSuccess } = {}) {
408
407
  const currentState = this.get();
409
408
  const model = currentState[names.model];
410
- const modelInput = cnst.purify(data);
409
+ const modelInput = cnst.input.purify(data);
411
410
  if (!modelInput)
412
411
  return;
413
412
  if (model?.id === id)
@@ -418,7 +417,7 @@ const makeActions = (refName, slices) => {
418
417
  [names.modelModal]: modal ?? null,
419
418
  ...typeof path === "string" && path ? { [path]: updatedModel } : {}
420
419
  });
421
- const updatedLightModel = cnst.lightCrystalize(updatedModel);
420
+ const updatedLightModel = new cnst.light().set(updatedModel);
422
421
  slices.forEach(({ sliceName: sliceName2 }) => {
423
422
  const namesOfSlice = {
424
423
  modelList: sliceName2.replace(names.model, names.modelList),
@@ -440,7 +439,7 @@ const makeActions = (refName, slices) => {
440
439
  id,
441
440
  fetchPolicyOptions
442
441
  );
443
- const lightModel = cnst.lightCrystalize(model);
442
+ const lightModel = new cnst.light().set(model);
444
443
  slices.forEach(({ sliceName }) => {
445
444
  const namesOfSlice = {
446
445
  modelList: sliceName.replace(names.model, names.modelList),
@@ -458,7 +457,7 @@ const makeActions = (refName, slices) => {
458
457
  const newModelList = new import_base.DataList(modelList);
459
458
  if (model.removedAt) {
460
459
  newModelList.delete(id);
461
- const newModelInsight = cnst.crystalizeInsight({
460
+ const newModelInsight = new cnst.insight().set({
462
461
  ...modelInsight,
463
462
  count: modelInsight.count - 1
464
463
  });
@@ -483,7 +482,7 @@ const makeActions = (refName, slices) => {
483
482
  const currentState = this.get();
484
483
  const modelForm = currentState[names.modelForm];
485
484
  const modelSubmit = currentState[names.modelSubmit];
486
- const modelInput = cnst.purify(modelForm);
485
+ const modelInput = cnst.input.purify(modelForm);
487
486
  this.set({ [names.modelSubmit]: { ...modelSubmit, disabled: !modelInput || disabled } });
488
487
  },
489
488
  [names.submitModel]: async function(option) {
@@ -535,7 +534,7 @@ const makeActions = (refName, slices) => {
535
534
  [names.model]: id === model?.id ? updatedModel : model,
536
535
  [names.modelLoading]: false
537
536
  });
538
- const updatedLightModel = cnst.lightCrystalize(updatedModel);
537
+ const updatedLightModel = new cnst.light().set(updatedModel);
539
538
  slices.forEach(({ sliceName }) => {
540
539
  const namesOfSlice = {
541
540
  modelList: sliceName.replace(names.model, names.modelList),
@@ -564,14 +563,17 @@ const makeActions = (refName, slices) => {
564
563
  const model = currentState[names.model];
565
564
  const isFull = firstModel instanceof modelRef;
566
565
  if (isFull) {
567
- const crystalizedModel = cnst.crystalize(firstModel);
566
+ const crystalizedModel = new cnst.full().set(firstModel);
568
567
  this.set({ [names.model]: crystalizedModel });
569
568
  } else if (model?.id === firstModel.id) {
570
- const crystalizedModel = cnst.crystalize({ ...model, ...firstModel });
569
+ const crystalizedModel = new cnst.full().set({
570
+ ...model,
571
+ ...firstModel
572
+ });
571
573
  this.set({ [names.model]: crystalizedModel });
572
574
  }
573
575
  const lightModels = fullOrLightModels.map(
574
- (fullOrLightModel) => cnst.lightCrystalize(fullOrLightModel)
576
+ (fullOrLightModel) => new cnst.light().set(fullOrLightModel)
575
577
  );
576
578
  slices.forEach(({ sliceName }) => {
577
579
  const namesOfSlice = {
@@ -631,7 +633,7 @@ const makeActions = (refName, slices) => {
631
633
  const initArgLength = Math.min(args.length, argLength);
632
634
  const initForm = { invalidate: false, ...args[argLength] ?? {} };
633
635
  const queryArgs = new Array(initArgLength).fill(null).map((_, i) => args[i]);
634
- const defaultModel = (0, import_signal.immerify)(modelRef, { ...cnst.getDefault(), ...initForm.default ?? {} });
636
+ const defaultModel = new cnst.full().set(initForm.default ?? {});
635
637
  this.set({ [names.defaultModel]: defaultModel });
636
638
  await this[namesOfSlice.refreshModel]({ ...initForm, queryArgs });
637
639
  },
@@ -11,10 +11,7 @@ import {
11
11
  lowerlize,
12
12
  pathSet
13
13
  } from "@akanjs/common";
14
- import {
15
- constantInfo,
16
- getFieldMetas
17
- } from "@akanjs/constant";
14
+ import { constantInfo } from "@akanjs/constant";
18
15
  import { msg } from "@akanjs/dictionary";
19
16
  import {
20
17
  immerify
@@ -53,7 +50,7 @@ const createDatabaseState = (refName) => {
53
50
  const baseState = {
54
51
  [names.model]: null,
55
52
  [names.modelLoading]: true,
56
- [names.modelForm]: cnst.getDefault(),
53
+ [names.modelForm]: new cnst.input(),
57
54
  [names.modelFormLoading]: true,
58
55
  [names.modelSubmit]: { disabled: true, loading: false, times: 0 },
59
56
  [names.modelViewAt]: /* @__PURE__ */ new Date(0),
@@ -100,13 +97,13 @@ const createSliceState = (refName, slices) => {
100
97
  sortOfModel: SliceName.replace(names.Model, names.sortOfModel)
101
98
  };
102
99
  const singleSliceState = {
103
- [namesOfSlice.defaultModel]: cnst.getDefault(),
100
+ [namesOfSlice.defaultModel]: new cnst.full(),
104
101
  [namesOfSlice.modelList]: new DataList(),
105
102
  [namesOfSlice.modelListLoading]: true,
106
103
  [namesOfSlice.modelInitList]: new DataList(),
107
104
  [namesOfSlice.modelInitAt]: /* @__PURE__ */ new Date(0),
108
105
  [namesOfSlice.modelSelection]: new DataList(),
109
- [namesOfSlice.modelInsight]: cnst.getDefaultInsight(),
106
+ [namesOfSlice.modelInsight]: new cnst.insight(),
110
107
  [namesOfSlice.lastPageOfModel]: 1,
111
108
  [namesOfSlice.pageOfModel]: 1,
112
109
  [namesOfSlice.limitOfModel]: 20,
@@ -120,7 +117,6 @@ const createSliceState = (refName, slices) => {
120
117
  const makeFormSetter = (refName) => {
121
118
  const [fieldName, className] = [refName, capitalize(refName)];
122
119
  const modelRef = constantInfo.getDatabase(refName).full;
123
- const fieldMetas = getFieldMetas(modelRef);
124
120
  const names = {
125
121
  model: fieldName,
126
122
  Model: className,
@@ -135,8 +131,8 @@ const makeFormSetter = (refName) => {
135
131
  });
136
132
  }
137
133
  };
138
- const fieldSetAction = fieldMetas.reduce((acc, fieldMeta) => {
139
- const [fieldKeyName, classKeyName] = [lowerlize(fieldMeta.key), capitalize(fieldMeta.key)];
134
+ const fieldSetAction = Object.entries(modelRef.field).reduce((acc, [key, field]) => {
135
+ const [fieldKeyName, classKeyName] = [lowerlize(key), capitalize(key)];
140
136
  const namesOfField = {
141
137
  field: fieldKeyName,
142
138
  Field: classKeyName,
@@ -149,18 +145,18 @@ const makeFormSetter = (refName) => {
149
145
  const singleFieldSetAction = {
150
146
  [namesOfField.setFieldOnModel]: function(value) {
151
147
  this.set((state) => {
152
- const setValue = fieldMeta.isClass ? immerify(fieldMeta.modelRef, value) : value;
148
+ const setValue = field.isClass ? immerify(field.modelRef, value) : value;
153
149
  state[names.modelForm][namesOfField.field] = setValue;
154
150
  });
155
151
  },
156
- ...fieldMeta.isArray ? {
152
+ ...field.isArray ? {
157
153
  [namesOfField.addFieldOnModel]: function(value, options = {}) {
158
154
  const form = this.get()[names.modelForm];
159
155
  const length = form[namesOfField.field].length;
160
156
  if (options.limit && options.limit <= length)
161
157
  return;
162
158
  const idx = options.idx ?? length;
163
- const setValue = fieldMeta.isClass ? immerify(fieldMeta.modelRef, value) : value;
159
+ const setValue = field.isClass ? immerify(field.modelRef, value) : value;
164
160
  this.set((state) => {
165
161
  state[names.modelForm][namesOfField.field] = [
166
162
  ...form[namesOfField.field].slice(0, idx),
@@ -184,7 +180,7 @@ const makeFormSetter = (refName) => {
184
180
  this[namesOfField.subFieldOnModel](index);
185
181
  }
186
182
  } : {},
187
- ...fieldMeta.isClass && constantInfo.getRefName(fieldMeta.modelRef) === "file" ? {
183
+ ...field.isClass && constantInfo.getRefName(field.modelRef) === "file" ? {
188
184
  [namesOfField.uploadFieldOnModel]: async function(fileList, index) {
189
185
  const form = this.get()[names.modelForm];
190
186
  if (!fileList.length)
@@ -193,7 +189,7 @@ const makeFormSetter = (refName) => {
193
189
  fileList,
194
190
  form.id
195
191
  );
196
- if (fieldMeta.isArray) {
192
+ if (field.isArray) {
197
193
  const idx = index ?? form[namesOfField.field].length;
198
194
  this.set((state) => {
199
195
  state[names.modelForm][namesOfField.field] = [
@@ -211,7 +207,7 @@ const makeFormSetter = (refName) => {
211
207
  const intervalKey = setInterval(() => {
212
208
  void (async () => {
213
209
  const currentFile = await fetch.file(file.id);
214
- if (fieldMeta.isArray)
210
+ if (field.isArray)
215
211
  this.set((state) => {
216
212
  state[names.modelForm][namesOfField.field] = state[names.modelForm][namesOfField.field].map(
217
213
  (file2) => file2.id === currentFile.id ? currentFile : file2
@@ -297,13 +293,13 @@ const makeActions = (refName, slices) => {
297
293
  const modelListLoading = currentState[namesOfSlice.modelListLoading];
298
294
  const modelInsight = currentState[namesOfSlice.modelInsight];
299
295
  const defaultModel = currentState[namesOfSlice.defaultModel];
300
- const modelInput = cnst.purify(modelForm);
296
+ const modelInput = cnst.input.purify(modelForm);
301
297
  if (!modelInput)
302
298
  return;
303
299
  this.set({ [names.modelLoading]: true });
304
300
  const model = await fetch[names.createModel](modelInput, { onError });
305
301
  const newModelList = modelListLoading ? modelList : new DataList([...modelList.slice(0, idx ?? 0), model, ...modelList.slice(idx ?? 0)]);
306
- const newModelInsight = cnst.crystalizeInsight({
302
+ const newModelInsight = new cnst.insight().set({
307
303
  ...modelInsight,
308
304
  count: modelInsight.count + 1
309
305
  });
@@ -328,7 +324,7 @@ const makeActions = (refName, slices) => {
328
324
  const model = currentState[names.model];
329
325
  const modelForm = currentState[names.modelForm];
330
326
  const defaultModel = currentState[namesOfSlice.defaultModel];
331
- const modelInput = cnst.purify(modelForm);
327
+ const modelInput = cnst.input.purify(modelForm);
332
328
  if (!modelInput)
333
329
  return;
334
330
  if (model?.id === modelForm.id)
@@ -342,7 +338,7 @@ const makeActions = (refName, slices) => {
342
338
  [names.modelModal]: modal ?? null,
343
339
  ...typeof path === "string" && path ? { [path]: updatedModel } : {}
344
340
  });
345
- const updatedLightModel = cnst.lightCrystalize(updatedModel);
341
+ const updatedLightModel = new cnst.light().set(updatedModel);
346
342
  slices.forEach(({ sliceName: sliceName2 }) => {
347
343
  const namesOfSlice2 = {
348
344
  modelList: sliceName2.replace(names.model, names.modelList),
@@ -370,13 +366,13 @@ const makeActions = (refName, slices) => {
370
366
  const modelList = currentState[namesOfSlice.modelList];
371
367
  const modelListLoading = currentState[namesOfSlice.modelListLoading];
372
368
  const modelInsight = currentState[namesOfSlice.modelInsight];
373
- const modelInput = cnst.purify(data);
369
+ const modelInput = cnst.input.purify(data);
374
370
  if (!modelInput)
375
371
  return;
376
372
  this.set({ [names.modelLoading]: true });
377
373
  const model = await fetch[names.createModel](modelInput, { onError });
378
374
  const newModelList = modelListLoading ? modelList : new DataList([...modelList.slice(0, idx ?? 0), model, ...modelList.slice(idx ?? 0)]);
379
- const newModelInsight = cnst.crystalizeInsight({
375
+ const newModelInsight = new cnst.insight().set({
380
376
  ...modelInsight,
381
377
  count: modelInsight.count + 1
382
378
  });
@@ -394,7 +390,7 @@ const makeActions = (refName, slices) => {
394
390
  [names.updateModel]: async function(id, data, { idx, path, modal, sliceName = names.model, onError, onSuccess } = {}) {
395
391
  const currentState = this.get();
396
392
  const model = currentState[names.model];
397
- const modelInput = cnst.purify(data);
393
+ const modelInput = cnst.input.purify(data);
398
394
  if (!modelInput)
399
395
  return;
400
396
  if (model?.id === id)
@@ -405,7 +401,7 @@ const makeActions = (refName, slices) => {
405
401
  [names.modelModal]: modal ?? null,
406
402
  ...typeof path === "string" && path ? { [path]: updatedModel } : {}
407
403
  });
408
- const updatedLightModel = cnst.lightCrystalize(updatedModel);
404
+ const updatedLightModel = new cnst.light().set(updatedModel);
409
405
  slices.forEach(({ sliceName: sliceName2 }) => {
410
406
  const namesOfSlice = {
411
407
  modelList: sliceName2.replace(names.model, names.modelList),
@@ -427,7 +423,7 @@ const makeActions = (refName, slices) => {
427
423
  id,
428
424
  fetchPolicyOptions
429
425
  );
430
- const lightModel = cnst.lightCrystalize(model);
426
+ const lightModel = new cnst.light().set(model);
431
427
  slices.forEach(({ sliceName }) => {
432
428
  const namesOfSlice = {
433
429
  modelList: sliceName.replace(names.model, names.modelList),
@@ -445,7 +441,7 @@ const makeActions = (refName, slices) => {
445
441
  const newModelList = new DataList(modelList);
446
442
  if (model.removedAt) {
447
443
  newModelList.delete(id);
448
- const newModelInsight = cnst.crystalizeInsight({
444
+ const newModelInsight = new cnst.insight().set({
449
445
  ...modelInsight,
450
446
  count: modelInsight.count - 1
451
447
  });
@@ -470,7 +466,7 @@ const makeActions = (refName, slices) => {
470
466
  const currentState = this.get();
471
467
  const modelForm = currentState[names.modelForm];
472
468
  const modelSubmit = currentState[names.modelSubmit];
473
- const modelInput = cnst.purify(modelForm);
469
+ const modelInput = cnst.input.purify(modelForm);
474
470
  this.set({ [names.modelSubmit]: { ...modelSubmit, disabled: !modelInput || disabled } });
475
471
  },
476
472
  [names.submitModel]: async function(option) {
@@ -522,7 +518,7 @@ const makeActions = (refName, slices) => {
522
518
  [names.model]: id === model?.id ? updatedModel : model,
523
519
  [names.modelLoading]: false
524
520
  });
525
- const updatedLightModel = cnst.lightCrystalize(updatedModel);
521
+ const updatedLightModel = new cnst.light().set(updatedModel);
526
522
  slices.forEach(({ sliceName }) => {
527
523
  const namesOfSlice = {
528
524
  modelList: sliceName.replace(names.model, names.modelList),
@@ -551,14 +547,17 @@ const makeActions = (refName, slices) => {
551
547
  const model = currentState[names.model];
552
548
  const isFull = firstModel instanceof modelRef;
553
549
  if (isFull) {
554
- const crystalizedModel = cnst.crystalize(firstModel);
550
+ const crystalizedModel = new cnst.full().set(firstModel);
555
551
  this.set({ [names.model]: crystalizedModel });
556
552
  } else if (model?.id === firstModel.id) {
557
- const crystalizedModel = cnst.crystalize({ ...model, ...firstModel });
553
+ const crystalizedModel = new cnst.full().set({
554
+ ...model,
555
+ ...firstModel
556
+ });
558
557
  this.set({ [names.model]: crystalizedModel });
559
558
  }
560
559
  const lightModels = fullOrLightModels.map(
561
- (fullOrLightModel) => cnst.lightCrystalize(fullOrLightModel)
560
+ (fullOrLightModel) => new cnst.light().set(fullOrLightModel)
562
561
  );
563
562
  slices.forEach(({ sliceName }) => {
564
563
  const namesOfSlice = {
@@ -618,7 +617,7 @@ const makeActions = (refName, slices) => {
618
617
  const initArgLength = Math.min(args.length, argLength);
619
618
  const initForm = { invalidate: false, ...args[argLength] ?? {} };
620
619
  const queryArgs = new Array(initArgLength).fill(null).map((_, i) => args[i]);
621
- const defaultModel = immerify(modelRef, { ...cnst.getDefault(), ...initForm.default ?? {} });
620
+ const defaultModel = new cnst.full().set(initForm.default ?? {});
622
621
  this.set({ [names.defaultModel]: defaultModel });
623
622
  await this[namesOfSlice.refreshModel]({ ...initForm, queryArgs });
624
623
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akanjs/store",
3
- "version": "1.0.5",
3
+ "version": "1.0.7-canary.0",
4
4
  "sourceType": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"