Created
November 26, 2023 14:25
-
-
Save suenot/a29cbc70ff07e9d0e8d782842661a4d5 to your computer and use it in GitHub Desktop.
Creating Empty Package
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { DeepClient } from "@deep-foundation/deeplinks/imports/client"; | |
import { TypesStore } from "./typesStore"; | |
import debug from "debug"; | |
const log = debug("create-empty-package"); | |
export const createEmptyPackage = async ({deep, Types, packageName, packageVersion}: { | |
deep: DeepClient, | |
packageName: string, | |
packageVersion: string, | |
Types: TypesStore, | |
}) => { | |
const { | |
PackageNamespaceId, | |
PackageVersionId, | |
PackageActiveId, | |
PackageId, | |
ContainId, | |
JoinId | |
} = Types; | |
console.log({packageName, packageVersion, PackageId, ContainId, JoinId}); | |
const npmPackagerId = await deep.id('@deep-foundation/npm-packager'); | |
const InstalledId = await deep.id('@deep-foundation/npm-packager', 'Installed'); | |
const usersPackages = await deep.id('deep', 'users', 'packages'); | |
const deepAdmin = await deep.id('deep', 'admin'); | |
// package | |
const { data: [{ id: packageId }] } = await deep.insert({ | |
type_id: PackageId, | |
string: { data: { value: packageName } }, | |
in: { data: [ | |
{ | |
type_id: ContainId, | |
from_id: deep.linkId, | |
}, | |
{ | |
type_id: ContainId, | |
from_id: npmPackagerId, | |
}, | |
//{ | |
// type_id: InstalledId, | |
// from_id: deepAdmin, | |
//}, | |
] }, | |
out: { data: [ | |
{ | |
type_id: JoinId, | |
to_id: usersPackages, | |
}, | |
{ | |
type_id: JoinId, | |
to_id: deepAdmin | |
}, | |
] }, | |
}); | |
log({packageId}); | |
// package namespace | |
const { data: [{ id: packageNamespaceId }] } = await deep.insert({ | |
type_id: PackageNamespaceId, | |
string: { data: { value: packageName } }, | |
in: { data: [ | |
{ | |
type_id: ContainId, | |
from_id: deep.linkId, | |
}, | |
{ | |
type_id: ContainId, | |
from_id: npmPackagerId, | |
}, | |
] }, | |
out: { data: [ | |
{ | |
type_id: ContainId, | |
to_id: packageId, | |
}, | |
{ | |
type_id: PackageVersionId, | |
to_id: packageId, | |
string: { data: { value: packageVersion } }, | |
}, | |
{ | |
type_id: PackageActiveId, | |
to_id: packageId, | |
}, | |
] }, | |
}); | |
console.log({packageNamespaceId}); | |
return {packageId, packageNamespaceId}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment