@liminalfunctions/framework-vitamins 1.0.6 → 1.0.7
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.
- package/LICENSE +7 -0
- package/package.json +1 -1
- package/src/vitamins.ts +4 -8
- package/test/0_0_basics.test.ts +1 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright 2025 Samuel Richardson
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/package.json
CHANGED
package/src/vitamins.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { v4 as uuid } from 'uuid'
|
|
2
|
-
import { App } from 'vue'
|
|
2
|
+
import { App, Ref } from 'vue'
|
|
3
3
|
import { generated_collection_interface, generated_document_interface, Infer_Collection_Returntype, result } from './type_generated_collection.js'
|
|
4
4
|
|
|
5
5
|
type query_operation = "get" | "query";
|
|
@@ -209,13 +209,13 @@ function quickprint(query: Query){
|
|
|
209
209
|
}
|
|
210
210
|
|
|
211
211
|
export class Vitamins {
|
|
212
|
-
vue: App
|
|
212
|
+
vue: App | any;
|
|
213
213
|
documents: Map<string, Document> // document id -> document
|
|
214
214
|
all_queries: Map<string, Query>
|
|
215
215
|
queries_by_collection: Map<string, Set<Query>>// collection id -> document[]
|
|
216
216
|
debug_on: boolean;
|
|
217
217
|
|
|
218
|
-
constructor(vue: App) {
|
|
218
|
+
constructor(vue: App | any) {
|
|
219
219
|
this.vue = vue;
|
|
220
220
|
this.documents = new Map();
|
|
221
221
|
this.queries_by_collection = new Map();
|
|
@@ -223,7 +223,7 @@ export class Vitamins {
|
|
|
223
223
|
this.debug_on = false;
|
|
224
224
|
}
|
|
225
225
|
|
|
226
|
-
document<
|
|
226
|
+
document<Document extends generated_document_interface<result>>(collection: Document, ...generators: child_generator<Infer_Collection_Returntype<Document>>[]): Query {
|
|
227
227
|
// if queries_by_collection does not yet have a key for the relevant collection, create one.
|
|
228
228
|
if(!this.queries_by_collection.has(collection.collection_id)){ this.queries_by_collection.set(collection.collection_id, new Set()); }
|
|
229
229
|
|
|
@@ -350,12 +350,10 @@ export class Vitamins {
|
|
|
350
350
|
*/
|
|
351
351
|
let cloned_data = structuredClone(data);
|
|
352
352
|
|
|
353
|
-
//@ts-expect-error
|
|
354
353
|
if(!this.vue[document.reference.collection_name_plural]){
|
|
355
354
|
throw new Error(`when updating ${document.reference.collection_name_plural}, found that the vue app does not have a ${document.reference.collection_name_plural} key`);
|
|
356
355
|
}
|
|
357
356
|
|
|
358
|
-
//@ts-expect-error
|
|
359
357
|
if(!(this.vue[document.reference.collection_name_plural] instanceof Map)){
|
|
360
358
|
throw new Error(`when updating ${document.reference.collection_name_plural}, found that the vue app key ${document.reference.collection_name_plural} is not a map. It should be a Map<string, ${document.reference.collection_name_plural}>`);
|
|
361
359
|
}
|
|
@@ -425,7 +423,6 @@ export class Vitamins {
|
|
|
425
423
|
}
|
|
426
424
|
|
|
427
425
|
this.documents.delete(document.id);
|
|
428
|
-
//@ts-expect-error
|
|
429
426
|
if(!this.vue[document.reference.collection_name_plural]){
|
|
430
427
|
throw new Error(`when updating ${document.reference.collection_name_plural}, found that the vue app does not have a ${document.reference.collection_name_plural} key`)
|
|
431
428
|
};
|
|
@@ -434,7 +431,6 @@ export class Vitamins {
|
|
|
434
431
|
if(!this.vue[document.reference.collection_name_plural] instanceof Map){
|
|
435
432
|
throw new Error(`when updating ${document.reference.collection_name_plural}, found that the vue app key ${document.reference.collection_name_plural} is not a map. It should be a Map<string, ${document.reference.collection_name_plural}>`)
|
|
436
433
|
};
|
|
437
|
-
//@ts-expect-error
|
|
438
434
|
this.vue[document.reference.collection_name_plural].delete(document.id);
|
|
439
435
|
}
|
|
440
436
|
}
|
package/test/0_0_basics.test.ts
CHANGED