(
owner: Owner,
entries: readonly {
readonly collection: string;
readonly key: string;
readonly data: unknown;
}[],
)
| 1640 | }); |
| 1641 | |
| 1642 | const putManyImpl = ( |
| 1643 | owner: Owner, |
| 1644 | entries: readonly { |
| 1645 | readonly collection: string; |
| 1646 | readonly key: string; |
| 1647 | readonly data: unknown; |
| 1648 | }[], |
| 1649 | ) => |
| 1650 | input.core.transaction( |
| 1651 | Effect.gen(function* () { |
| 1652 | const os = ownerSubject(owner); |
| 1653 | if (!os) { |
| 1654 | return yield* new StorageError({ |
| 1655 | message: `Cannot write plugin storage for owner "user": executor has no subject.`, |
| 1656 | cause: undefined, |
| 1657 | }); |
| 1658 | } |
| 1659 | const entriesById = new Map( |
| 1660 | entries.map((entry) => [ |
| 1661 | pluginStorageId({ |
| 1662 | pluginId: input.pluginId, |
| 1663 | collection: entry.collection, |
| 1664 | key: entry.key, |
| 1665 | }), |
| 1666 | entry, |
| 1667 | ]), |
| 1668 | ); |
| 1669 | const uniqueEntries = [...entriesById.values()]; |
| 1670 | if (uniqueEntries.length === 0) return; |
| 1671 | |
| 1672 | const now = new Date(); |
| 1673 | yield* input.core.upsertMany("plugin_storage", { |
| 1674 | target: ["tenant", "owner", "subject", "plugin_id", "collection", "key"], |
| 1675 | update: ["data", "updated_at"], |
| 1676 | values: uniqueEntries.map((entry) => ({ |
| 1677 | tenant, |
| 1678 | owner: os.owner, |
| 1679 | subject: os.subject, |
| 1680 | plugin_id: input.pluginId, |
| 1681 | collection: entry.collection, |
| 1682 | key: entry.key, |
| 1683 | data: entry.data, |
| 1684 | created_at: now, |
| 1685 | updated_at: now, |
| 1686 | })), |
| 1687 | }); |
| 1688 | }), |
| 1689 | ); |
| 1690 | |
| 1691 | const removeManyImpl = ( |
| 1692 | owner: Owner, |
no test coverage detected