@learncard/core 8.1.1 → 8.2.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.
- package/dist/core.cjs.development.js +37 -2
- package/dist/core.cjs.development.js.map +2 -2
- package/dist/core.cjs.production.min.js +61 -61
- package/dist/core.cjs.production.min.js.map +3 -3
- package/dist/core.d.ts +2 -1
- package/dist/core.esm.js +37 -2
- package/dist/core.esm.js.map +2 -2
- package/package.json +1 -1
package/dist/core.d.ts
CHANGED
@@ -4751,7 +4751,8 @@ export declare type LearnCardStorePlane<Plugins extends Plugin[]> = Record<Filte
|
|
4751
4751
|
};
|
4752
4752
|
export declare type IndexPlane = {
|
4753
4753
|
get: <Metadata extends Record<string, any> = Record<never, never>>(query?: Record<string, any>, options?: PlaneOptions) => Promise<CredentialRecord<Metadata>[]>;
|
4754
|
-
add: <Metadata extends Record<string, any> = Record<never, never>>(
|
4754
|
+
add: <Metadata extends Record<string, any> = Record<never, never>>(record: CredentialRecord<Metadata>, options?: PlaneOptions) => Promise<boolean>;
|
4755
|
+
addMany?: <Metadata extends Record<string, any> = Record<never, never>>(records: CredentialRecord<Metadata>[], options?: PlaneOptions) => Promise<boolean>;
|
4755
4756
|
update: (id: string, updates: Record<string, any>, options?: PlaneOptions) => Promise<boolean>;
|
4756
4757
|
remove: (id: string, options?: PlaneOptions) => Promise<boolean>;
|
4757
4758
|
removeAll?: (options?: PlaneOptions) => Promise<boolean>;
|
package/dist/core.esm.js
CHANGED
@@ -46330,6 +46330,14 @@ var addCachingToIndexPlane = /* @__PURE__ */ __name((plane, name5) => ({
|
|
46330
46330
|
}
|
46331
46331
|
return plane.add(_learnCard, record);
|
46332
46332
|
},
|
46333
|
+
...plane.addMany ? {
|
46334
|
+
addMany: async (_learnCard, records, { cache = "cache-first" } = {}) => {
|
46335
|
+
if (cache !== "skip-cache" && learnCardImplementsPlane(_learnCard, "cache")) {
|
46336
|
+
await _learnCard.cache.flushIndex();
|
46337
|
+
}
|
46338
|
+
return plane.addMany?.(_learnCard, records);
|
46339
|
+
}
|
46340
|
+
} : {},
|
46333
46341
|
update: async (_learnCard, id, update2, { cache = "cache-first" } = {}) => {
|
46334
46342
|
if (cache !== "skip-cache" && learnCardImplementsPlane(_learnCard, "cache")) {
|
46335
46343
|
await _learnCard.cache.flushIndex();
|
@@ -67650,8 +67658,8 @@ var getIDXPlugin = /* @__PURE__ */ __name(async (learnCard, { modelData, credent
|
|
67650
67658
|
alias = credentialAlias;
|
67651
67659
|
return dataStore.set(alias, { credentials: [] });
|
67652
67660
|
}, "removeAllCredentialsFromIdx");
|
67653
|
-
const addCredentialInIdx = /* @__PURE__ */ __name(async (
|
67654
|
-
const record = CredentialRecordValidator.
|
67661
|
+
const addCredentialInIdx = /* @__PURE__ */ __name(async (_record) => {
|
67662
|
+
const record = await CredentialRecordValidator.parseAsync(_record);
|
67655
67663
|
if (!record)
|
67656
67664
|
throw new Error("record is required");
|
67657
67665
|
if (!record.uri)
|
@@ -67667,6 +67675,23 @@ var getIDXPlugin = /* @__PURE__ */ __name(async (learnCard, { modelData, credent
|
|
67667
67675
|
existing.credentials.push(record);
|
67668
67676
|
return streamIdToCeramicURI(await dataStore.set(credentialAlias, existing));
|
67669
67677
|
}, "addCredentialInIdx");
|
67678
|
+
const addCredentialsInIdx = /* @__PURE__ */ __name(async (_records) => {
|
67679
|
+
const records = CredentialRecordValidator.array().parse(_records);
|
67680
|
+
const existing = await getCredentialsListFromIdx(credentialAlias);
|
67681
|
+
await Promise.all(
|
67682
|
+
records.map(async (record) => {
|
67683
|
+
await learnCard.read.get(record.uri);
|
67684
|
+
const indexOfExistingCredential = existing.credentials.findIndex((credential) => {
|
67685
|
+
return credential.id === record.id;
|
67686
|
+
});
|
67687
|
+
if (indexOfExistingCredential > -1) {
|
67688
|
+
existing.credentials[indexOfExistingCredential] = record;
|
67689
|
+
} else
|
67690
|
+
existing.credentials.push(record);
|
67691
|
+
})
|
67692
|
+
);
|
67693
|
+
return streamIdToCeramicURI(await dataStore.set(credentialAlias, existing));
|
67694
|
+
}, "addCredentialsInIdx");
|
67670
67695
|
return {
|
67671
67696
|
name: "IDX",
|
67672
67697
|
displayName: "IDX",
|
@@ -67687,6 +67712,16 @@ var getIDXPlugin = /* @__PURE__ */ __name(async (learnCard, { modelData, credent
|
|
67687
67712
|
return false;
|
67688
67713
|
}
|
67689
67714
|
},
|
67715
|
+
addMany: async (_learnCard, records) => {
|
67716
|
+
_learnCard.debug?.("learnCard.index.IDX.add");
|
67717
|
+
try {
|
67718
|
+
await addCredentialsInIdx(records);
|
67719
|
+
return true;
|
67720
|
+
} catch (error) {
|
67721
|
+
console.error("Error adding credential with IDX:", error);
|
67722
|
+
return false;
|
67723
|
+
}
|
67724
|
+
},
|
67690
67725
|
update: async (_learnCard) => {
|
67691
67726
|
_learnCard.debug?.("learnCard.index.IDX.update");
|
67692
67727
|
return false;
|