(plugin: Plugin)
| 6 | |
| 7 | export const pluginCollectionMethods = { |
| 8 | async upsertPlugin(plugin: Plugin) { |
| 9 | const now = C.getDate().getTime() |
| 10 | await rd.exec( |
| 11 | `INSERT INTO plugin (name,version,dependencies,created,edited,script) |
| 12 | VALUES ( ?, ?, ?, ?, ?, ?) |
| 13 | ON CONFLICT(name) DO UPDATE SET |
| 14 | version=excluded.version, |
| 15 | dependencies=excluded.dependencies, |
| 16 | edited=excluded.edited, |
| 17 | script=excluded.script`, |
| 18 | // lowTODO add conflict types via typescript, i.e. "point of this type is to cause an error if something is added to Plugin" |
| 19 | [ |
| 20 | plugin.name, |
| 21 | plugin.version, |
| 22 | plugin.dependencies ?? null, |
| 23 | now, |
| 24 | now, |
| 25 | new Uint8Array(await plugin.script.arrayBuffer()), |
| 26 | ], |
| 27 | ) |
| 28 | }, |
| 29 | async getPlugins(): Promise<Plugin[]> { |
| 30 | const plugins = await ky.selectFrom('plugin').selectAll().execute() |
| 31 | return plugins.map(pluginEntityToDomain) |
nothing calls this directly
no outgoing calls
no test coverage detected