@teambit/workspace 1.0.547 → 1.0.548
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/{preview-1739904952910.js → preview-1739935256478.js} +2 -2
- package/dist/ui/workspace/use-workspace.js +1 -1
- package/dist/ui/workspace/use-workspace.js.map +1 -1
- package/dist/workspace.graphql.d.ts +3 -0
- package/dist/workspace.graphql.js +6 -3
- package/dist/workspace.graphql.js.map +1 -1
- package/package.json +25 -25
- package/ui/workspace/use-workspace.ts +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.workspace_workspace@1.0.
|
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.workspace_workspace@1.0.
|
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.workspace_workspace@1.0.548/dist/workspace.composition.js';
|
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.workspace_workspace@1.0.548/dist/workspace.docs.mdx';
|
|
3
3
|
|
|
4
4
|
export const compositions = [compositions_0];
|
|
5
5
|
export const overview = [overview_0];
|
|
@@ -210,7 +210,7 @@ function useWorkspace(options = {}) {
|
|
|
210
210
|
updateQuery: (prev, {
|
|
211
211
|
subscriptionData
|
|
212
212
|
}) => {
|
|
213
|
-
const idsToRemove = subscriptionData
|
|
213
|
+
const idsToRemove = subscriptionData?.data?.componentRemoved?.componentIds;
|
|
214
214
|
if (!idsToRemove || idsToRemove.length === 0) return prev;
|
|
215
215
|
|
|
216
216
|
// side effect - trigger observers
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","data","require","_component","_latest","_interopRequireDefault","_uiFoundationUiHooks","_client","_componentId","_workspaceModel","_excluded","e","__esModule","default","ownKeys","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","_objectWithoutProperties","_objectWithoutPropertiesLoose","n","indexOf","propertyIsEnumerable","hasOwnProperty","wcComponentFields","gql","WORKSPACE","COMPONENT_SUBSCRIPTION_ADDED","COMPONENT_SUBSCRIPTION_CHANGED","COMPONENT_SUBSCRIPTION_REMOVED","useWorkspace","options","_useDataQuery","useDataQuery","subscribeToMore","rest","optionsRef","useLatest","useEffect","unSubCompAddition","document","updateQuery","prev","subscriptionData","update","addedComponent","componentAdded","component","componentExists","workspace","components","find","ComponentID","isEqualObj","id","ignoreVersion","setTimeout","current","onComponentAdded","ComponentModel","from","unSubCompChange","updatedComponent","componentChanged","onComponentUpdated","map","name","unSubCompRemoved","idsToRemove","componentRemoved","componentIds","onComponentRemoved","fromObject","every","useMemo","Workspace","undefined"],"sources":["use-workspace.ts"],"sourcesContent":["import { useEffect, useMemo } from 'react';\nimport { ComponentModel } from '@teambit/component';\nimport useLatest from '@react-hook/latest';\nimport { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query';\nimport { gql } from '@apollo/client';\nimport { ComponentID, ComponentIdObj } from '@teambit/component-id';\n\nimport { Workspace } from './workspace-model';\n\ntype UseWorkspaceOptions = {\n onComponentAdded?: (component: ComponentModel[]) => void;\n onComponentUpdated?: (component: ComponentModel[]) => void;\n onComponentRemoved?: (compId: ComponentID[]) => void;\n};\ntype RawComponent = { id: ComponentIdObj };\n\nconst wcComponentFields = gql`\n fragment wcComponentFields on Component {\n id {\n name\n version\n scope\n }\n aspects(include: [\"teambit.preview/preview\", \"teambit.envs/envs\"]) {\n # 'id' property in gql refers to a *global* identifier and used for caching.\n # this makes aspect data cache under the same key, even when they are under different components.\n # renaming the property fixes that.\n aspectId: id\n data\n }\n compositions {\n identifier\n }\n description\n issuesCount\n status {\n isOutdated\n isNew\n isInScope\n isStaged\n modifyInfo {\n hasModifiedFiles\n hasModifiedDependencies\n }\n isDeleted\n }\n buildStatus\n preview {\n includesEnvTemplate\n legacyHeader\n isScaling\n skipIncludes\n }\n deprecation {\n isDeprecate\n newId\n }\n server {\n env\n url\n }\n env {\n id\n icon\n }\n }\n`;\n\nconst WORKSPACE = gql`\n query workspace {\n workspace {\n name\n path\n icon\n components {\n ...wcComponentFields\n }\n }\n }\n ${wcComponentFields}\n`;\n\nconst COMPONENT_SUBSCRIPTION_ADDED = gql`\n subscription OnComponentAdded {\n componentAdded {\n component {\n ...wcComponentFields\n }\n }\n }\n ${wcComponentFields}\n`;\n\nconst COMPONENT_SUBSCRIPTION_CHANGED = gql`\n subscription OnComponentChanged {\n componentChanged {\n component {\n ...wcComponentFields\n }\n }\n }\n ${wcComponentFields}\n`;\n\nconst COMPONENT_SUBSCRIPTION_REMOVED = gql`\n subscription OnComponentRemoved {\n componentRemoved {\n componentIds {\n name\n version\n scope\n }\n }\n }\n`;\n\nexport function useWorkspace(options: UseWorkspaceOptions = {}) {\n const { data, subscribeToMore, ...rest } = useDataQuery(WORKSPACE);\n const optionsRef = useLatest(options);\n\n useEffect(() => {\n const unSubCompAddition = subscribeToMore({\n document: COMPONENT_SUBSCRIPTION_ADDED,\n updateQuery: (prev, { subscriptionData }) => {\n const update = subscriptionData.data;\n const addedComponent = update?.componentAdded?.component;\n if (!addedComponent) return prev;\n\n const componentExists = prev.workspace.components.find((component: any) =>\n ComponentID.isEqualObj(component.id, addedComponent.id, { ignoreVersion: true })\n );\n if (componentExists) return prev;\n\n // side effect - trigger observers\n setTimeout(() => optionsRef.current.onComponentAdded?.([ComponentModel.from(addedComponent)]));\n\n return {\n ...prev,\n workspace: {\n ...prev.workspace,\n components: [...prev.workspace.components, addedComponent],\n },\n };\n },\n });\n\n const unSubCompChange = subscribeToMore({\n document: COMPONENT_SUBSCRIPTION_CHANGED,\n updateQuery: (prev, { subscriptionData }) => {\n const update = subscriptionData.data;\n if (!update) return prev;\n\n const updatedComponent = update.componentChanged.component;\n // side effect - trigger observers\n setTimeout(() => optionsRef.current.onComponentUpdated?.([ComponentModel.from(updatedComponent)]));\n\n return {\n ...prev,\n workspace: {\n ...prev.workspace,\n components: prev.workspace.components.map((component) =>\n component.id.name === updatedComponent.id.name ? updatedComponent : component\n ),\n },\n };\n },\n });\n\n const unSubCompRemoved = subscribeToMore({\n document: COMPONENT_SUBSCRIPTION_REMOVED,\n updateQuery: (prev, { subscriptionData }) => {\n const idsToRemove: ComponentIdObj[] | undefined = subscriptionData.data?.componentRemoved?.componentIds;\n if (!idsToRemove || idsToRemove.length === 0) return prev;\n\n // side effect - trigger observers\n setTimeout(() => optionsRef.current.onComponentRemoved?.(idsToRemove.map((id) => ComponentID.fromObject(id))));\n\n return {\n ...prev,\n workspace: {\n ...prev.workspace,\n components: prev.workspace.components.filter((component: RawComponent) =>\n idsToRemove.every((id) => !ComponentID.isEqualObj(id, component.id))\n ),\n },\n };\n },\n });\n\n // TODO - sub to component removal\n\n return () => {\n unSubCompAddition();\n unSubCompChange();\n unSubCompRemoved();\n };\n }, [optionsRef]);\n\n const workspace = useMemo(() => {\n return data?.workspace ? Workspace.from(data?.workspace) : undefined;\n }, [data?.workspace]);\n\n return {\n workspace,\n subscribeToMore,\n ...rest,\n };\n}\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,WAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,UAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,QAAA;EAAA,MAAAH,IAAA,GAAAI,sBAAA,CAAAH,OAAA;EAAAE,OAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,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;QAEzD;QACAc,UAAU,CAAC,MAAMpB,UAAU,CAACqB,OAAO,CAACc,kBAAkB,GAAGH,WAAW,CAACH,GAAG,CAAEX,EAAE,IAAKF,0BAAW,CAACoB,UAAU,CAAClB,EAAE,CAAC,CAAC,CAAC,CAAC;QAE9G,OAAAxD,aAAA,CAAAA,aAAA,KACK4C,IAAI;UACPO,SAAS,EAAAnD,aAAA,CAAAA,aAAA,KACJ4C,IAAI,CAACO,SAAS;YACjBC,UAAU,EAAER,IAAI,CAACO,SAAS,CAACC,UAAU,CAACzD,MAAM,CAAEsD,SAAuB,IACnEqB,WAAW,CAACK,KAAK,CAAEnB,EAAE,IAAK,CAACF,0BAAW,CAACC,UAAU,CAACC,EAAE,EAAEP,SAAS,CAACO,EAAE,CAAC,CACrE;UAAC;QACF;MAEL;IACF,CAAC,CAAC;;IAEF;;IAEA,OAAO,MAAM;MACXf,iBAAiB,CAAC,CAAC;MACnBsB,eAAe,CAAC,CAAC;MACjBM,gBAAgB,CAAC,CAAC;IACpB,CAAC;EACH,CAAC,EAAE,CAAC/B,UAAU,CAAC,CAAC;EAEhB,MAAMa,SAAS,GAAG,IAAAyB,gBAAO,EAAC,MAAM;IAC9B,OAAOrG,IAAI,EAAE4E,SAAS,GAAG0B,2BAAS,CAACf,IAAI,CAACvF,IAAI,EAAE4E,SAAS,CAAC,GAAG2B,SAAS;EACtE,CAAC,EAAE,CAACvG,IAAI,EAAE4E,SAAS,CAAC,CAAC;EAErB,OAAAnD,aAAA;IACEmD,SAAS;IACTf;EAAe,GACZC,IAAI;AAEX","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_react","data","require","_component","_latest","_interopRequireDefault","_uiFoundationUiHooks","_client","_componentId","_workspaceModel","_excluded","e","__esModule","default","ownKeys","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","_objectWithoutProperties","_objectWithoutPropertiesLoose","n","indexOf","propertyIsEnumerable","hasOwnProperty","wcComponentFields","gql","WORKSPACE","COMPONENT_SUBSCRIPTION_ADDED","COMPONENT_SUBSCRIPTION_CHANGED","COMPONENT_SUBSCRIPTION_REMOVED","useWorkspace","options","_useDataQuery","useDataQuery","subscribeToMore","rest","optionsRef","useLatest","useEffect","unSubCompAddition","document","updateQuery","prev","subscriptionData","update","addedComponent","componentAdded","component","componentExists","workspace","components","find","ComponentID","isEqualObj","id","ignoreVersion","setTimeout","current","onComponentAdded","ComponentModel","from","unSubCompChange","updatedComponent","componentChanged","onComponentUpdated","map","name","unSubCompRemoved","idsToRemove","componentRemoved","componentIds","onComponentRemoved","fromObject","every","useMemo","Workspace","undefined"],"sources":["use-workspace.ts"],"sourcesContent":["import { useEffect, useMemo } from 'react';\nimport { ComponentModel } from '@teambit/component';\nimport useLatest from '@react-hook/latest';\nimport { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query';\nimport { gql } from '@apollo/client';\nimport { ComponentID, ComponentIdObj } from '@teambit/component-id';\n\nimport { Workspace } from './workspace-model';\n\ntype UseWorkspaceOptions = {\n onComponentAdded?: (component: ComponentModel[]) => void;\n onComponentUpdated?: (component: ComponentModel[]) => void;\n onComponentRemoved?: (compId: ComponentID[]) => void;\n};\ntype RawComponent = { id: ComponentIdObj };\n\nconst wcComponentFields = gql`\n fragment wcComponentFields on Component {\n id {\n name\n version\n scope\n }\n aspects(include: [\"teambit.preview/preview\", \"teambit.envs/envs\"]) {\n # 'id' property in gql refers to a *global* identifier and used for caching.\n # this makes aspect data cache under the same key, even when they are under different components.\n # renaming the property fixes that.\n aspectId: id\n data\n }\n compositions {\n identifier\n }\n description\n issuesCount\n status {\n isOutdated\n isNew\n isInScope\n isStaged\n modifyInfo {\n hasModifiedFiles\n hasModifiedDependencies\n }\n isDeleted\n }\n buildStatus\n preview {\n includesEnvTemplate\n legacyHeader\n isScaling\n skipIncludes\n }\n deprecation {\n isDeprecate\n newId\n }\n server {\n env\n url\n }\n env {\n id\n icon\n }\n }\n`;\n\nconst WORKSPACE = gql`\n query workspace {\n workspace {\n name\n path\n icon\n components {\n ...wcComponentFields\n }\n }\n }\n ${wcComponentFields}\n`;\n\nconst COMPONENT_SUBSCRIPTION_ADDED = gql`\n subscription OnComponentAdded {\n componentAdded {\n component {\n ...wcComponentFields\n }\n }\n }\n ${wcComponentFields}\n`;\n\nconst COMPONENT_SUBSCRIPTION_CHANGED = gql`\n subscription OnComponentChanged {\n componentChanged {\n component {\n ...wcComponentFields\n }\n }\n }\n ${wcComponentFields}\n`;\n\nconst COMPONENT_SUBSCRIPTION_REMOVED = gql`\n subscription OnComponentRemoved {\n componentRemoved {\n componentIds {\n name\n version\n scope\n }\n }\n }\n`;\n\nexport function useWorkspace(options: UseWorkspaceOptions = {}) {\n const { data, subscribeToMore, ...rest } = useDataQuery(WORKSPACE);\n const optionsRef = useLatest(options);\n\n useEffect(() => {\n const unSubCompAddition = subscribeToMore({\n document: COMPONENT_SUBSCRIPTION_ADDED,\n updateQuery: (prev, { subscriptionData }) => {\n const update = subscriptionData.data;\n const addedComponent = update?.componentAdded?.component;\n if (!addedComponent) return prev;\n\n const componentExists = prev.workspace.components.find((component: any) =>\n ComponentID.isEqualObj(component.id, addedComponent.id, { ignoreVersion: true })\n );\n if (componentExists) return prev;\n\n // side effect - trigger observers\n setTimeout(() => optionsRef.current.onComponentAdded?.([ComponentModel.from(addedComponent)]));\n\n return {\n ...prev,\n workspace: {\n ...prev.workspace,\n components: [...prev.workspace.components, addedComponent],\n },\n };\n },\n });\n\n const unSubCompChange = subscribeToMore({\n document: COMPONENT_SUBSCRIPTION_CHANGED,\n updateQuery: (prev, { subscriptionData }) => {\n const update = subscriptionData.data;\n if (!update) return prev;\n\n const updatedComponent = update.componentChanged.component;\n // side effect - trigger observers\n setTimeout(() => optionsRef.current.onComponentUpdated?.([ComponentModel.from(updatedComponent)]));\n\n return {\n ...prev,\n workspace: {\n ...prev.workspace,\n components: prev.workspace.components.map((component) =>\n component.id.name === updatedComponent.id.name ? updatedComponent : component\n ),\n },\n };\n },\n });\n\n const unSubCompRemoved = subscribeToMore({\n document: COMPONENT_SUBSCRIPTION_REMOVED,\n updateQuery: (prev, { subscriptionData }) => {\n const idsToRemove: ComponentIdObj[] | undefined = subscriptionData?.data?.componentRemoved?.componentIds;\n if (!idsToRemove || idsToRemove.length === 0) return prev;\n\n // side effect - trigger observers\n setTimeout(() => optionsRef.current.onComponentRemoved?.(idsToRemove.map((id) => ComponentID.fromObject(id))));\n\n return {\n ...prev,\n workspace: {\n ...prev.workspace,\n components: prev.workspace.components.filter((component: RawComponent) =>\n idsToRemove.every((id) => !ComponentID.isEqualObj(id, component.id))\n ),\n },\n };\n },\n });\n\n // TODO - sub to component removal\n\n return () => {\n unSubCompAddition();\n unSubCompChange();\n unSubCompRemoved();\n };\n }, [optionsRef]);\n\n const workspace = useMemo(() => {\n return data?.workspace ? Workspace.from(data?.workspace) : undefined;\n }, [data?.workspace]);\n\n return {\n workspace,\n subscribeToMore,\n ...rest,\n };\n}\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,WAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,UAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,QAAA;EAAA,MAAAH,IAAA,GAAAI,sBAAA,CAAAH,OAAA;EAAAE,OAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,qBAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,oBAAA,YAAAA,CAAA;IAAA,OAAA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EAAE,IAAKF,0BAAW,CAACoB,UAAU,CAAClB,EAAE,CAAC,CAAC,CAAC,CAAC;QAE9G,OAAAxD,aAAA,CAAAA,aAAA,KACK4C,IAAI;UACPO,SAAS,EAAAnD,aAAA,CAAAA,aAAA,KACJ4C,IAAI,CAACO,SAAS;YACjBC,UAAU,EAAER,IAAI,CAACO,SAAS,CAACC,UAAU,CAACzD,MAAM,CAAEsD,SAAuB,IACnEqB,WAAW,CAACK,KAAK,CAAEnB,EAAE,IAAK,CAACF,0BAAW,CAACC,UAAU,CAACC,EAAE,EAAEP,SAAS,CAACO,EAAE,CAAC,CACrE;UAAC;QACF;MAEL;IACF,CAAC,CAAC;;IAEF;;IAEA,OAAO,MAAM;MACXf,iBAAiB,CAAC,CAAC;MACnBsB,eAAe,CAAC,CAAC;MACjBM,gBAAgB,CAAC,CAAC;IACpB,CAAC;EACH,CAAC,EAAE,CAAC/B,UAAU,CAAC,CAAC;EAEhB,MAAMa,SAAS,GAAG,IAAAyB,gBAAO,EAAC,MAAM;IAC9B,OAAOrG,IAAI,EAAE4E,SAAS,GAAG0B,2BAAS,CAACf,IAAI,CAACvF,IAAI,EAAE4E,SAAS,CAAC,GAAG2B,SAAS;EACtE,CAAC,EAAE,CAACvG,IAAI,EAAE4E,SAAS,CAAC,CAAC;EAErB,OAAAnD,aAAA;IACEmD,SAAS;IACTf;EAAe,GACZC,IAAI;AAEX","ignoreList":[]}
|
|
@@ -7,12 +7,15 @@ declare const _default: (workspace: Workspace, graphql: GraphqlMain) => {
|
|
|
7
7
|
Subscription: {
|
|
8
8
|
componentAdded: {
|
|
9
9
|
subscribe: () => AsyncIterator<unknown, any, undefined>;
|
|
10
|
+
resolve: (payload: any) => any;
|
|
10
11
|
};
|
|
11
12
|
componentChanged: {
|
|
12
13
|
subscribe: () => AsyncIterator<unknown, any, undefined>;
|
|
14
|
+
resolve: (payload: any) => any;
|
|
13
15
|
};
|
|
14
16
|
componentRemoved: {
|
|
15
17
|
subscribe: () => AsyncIterator<unknown, any, undefined>;
|
|
18
|
+
resolve: (payload: any) => any;
|
|
16
19
|
};
|
|
17
20
|
};
|
|
18
21
|
Component: {
|
|
@@ -102,13 +102,16 @@ var _default = (workspace, graphql) => {
|
|
|
102
102
|
resolvers: {
|
|
103
103
|
Subscription: {
|
|
104
104
|
componentAdded: {
|
|
105
|
-
subscribe: () => graphql.pubsub.asyncIterator(_workspace().ComponentAdded)
|
|
105
|
+
subscribe: () => graphql.pubsub.asyncIterator(_workspace().ComponentAdded),
|
|
106
|
+
resolve: payload => payload.componentAdded
|
|
106
107
|
},
|
|
107
108
|
componentChanged: {
|
|
108
|
-
subscribe: () => graphql.pubsub.asyncIterator(_workspace().ComponentChanged)
|
|
109
|
+
subscribe: () => graphql.pubsub.asyncIterator(_workspace().ComponentChanged),
|
|
110
|
+
resolve: payload => payload.componentChanged
|
|
109
111
|
},
|
|
110
112
|
componentRemoved: {
|
|
111
|
-
subscribe: () => graphql.pubsub.asyncIterator(_workspace().ComponentRemoved)
|
|
113
|
+
subscribe: () => graphql.pubsub.asyncIterator(_workspace().ComponentRemoved),
|
|
114
|
+
resolve: payload => payload.componentRemoved
|
|
112
115
|
}
|
|
113
116
|
},
|
|
114
117
|
Component: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_graphqlTag","data","require","_workspace","_default","workspace","graphql","typeDefs","gql","resolvers","Subscription","componentAdded","subscribe","pubsub","asyncIterator","ComponentAdded","componentChanged","ComponentChanged","componentRemoved","ComponentRemoved","Component","status","wsComponent","getStatus","issuesCount","getIssues","count","issues","toObjectWithDataAsString","Workspace","path","ws","name","icon","components","offset","limit","list","getComponent","id","componentID","resolveComponentId","component","get","Query","exports","default"],"sources":["workspace.graphql.ts"],"sourcesContent":["import { GraphqlMain } from '@teambit/graphql';\nimport { gql } from 'graphql-tag';\n\nimport { ComponentAdded, ComponentChanged, ComponentRemoved, Workspace } from './workspace';\nimport { WorkspaceComponent } from './workspace-component';\n\nexport default (workspace: Workspace, graphql: GraphqlMain) => {\n return {\n typeDefs: gql`\n type ModifyInfo {\n # is the component modified.\n hasModifiedFiles: Boolean\n\n # the component has Modified Dependencies\n hasModifiedDependencies: Boolean\n }\n\n type ComponentStatus {\n # component is pending to be tagged automatically.\n modifyInfo: ModifyInfo\n\n # is the new component new.\n isNew: Boolean\n\n # is the component deleted from the workspace.\n isDeleted: Boolean\n\n # is the component staged.\n isStaged: Boolean\n\n # does the component exists in the workspace.\n isInWorkspace: Boolean\n\n # does the component exists in the scope.\n isInScope: Boolean\n\n # does the component is outdated (pending for update).\n isOutdated: Boolean\n }\n\n extend type Component {\n status: ComponentStatus\n }\n\n type Issue {\n type: String!\n description: String!\n solution: String\n data: String\n }\n\n extend type Component {\n # the count of errors in component in workspace\n issuesCount: Int\n issues: [Issue]\n }\n\n type Workspace {\n name: String\n path: String\n icon: String\n components(offset: Int, limit: Int): [Component]\n getComponent(id: String!): Component\n }\n\n type Subscription {\n componentAdded: ComponentAdded\n componentChanged: ComponentChanged\n componentRemoved: ComponentRemoved\n }\n\n type ComponentAdded {\n component: Component\n }\n\n type ComponentChanged {\n component: Component\n }\n\n type ComponentRemoved {\n componentIds: [ComponentID]\n }\n\n type Query {\n workspace: Workspace\n }\n `,\n resolvers: {\n Subscription: {\n componentAdded: {\n subscribe: () => graphql.pubsub.asyncIterator(ComponentAdded),\n },\n componentChanged: {\n subscribe: () => graphql.pubsub.asyncIterator(ComponentChanged),\n },\n componentRemoved: {\n subscribe: () => graphql.pubsub.asyncIterator(ComponentRemoved),\n },\n },\n Component: {\n status: async (wsComponent: WorkspaceComponent) => {\n return wsComponent.getStatus();\n },\n issuesCount: (wsComponent: WorkspaceComponent): number => {\n return wsComponent.getIssues()?.count || 0;\n },\n issues: (wsComponent: WorkspaceComponent) => {\n return wsComponent.getIssues()?.toObjectWithDataAsString();\n },\n },\n Workspace: {\n path: (ws) => ws.path,\n name: (ws) => ws.name,\n icon: (ws) => ws.icon,\n components: async (ws: Workspace, { offset, limit }: { offset: number; limit: number }) => {\n return ws.list({ offset, limit });\n },\n getComponent: async (ws: Workspace, { id }: { id: string }) => {\n try {\n const componentID = await ws.resolveComponentId(id);\n const component = await ws.get(componentID);\n return component;\n } catch {\n return null;\n }\n },\n },\n Query: {\n workspace: () => workspace,\n },\n },\n };\n};\n"],"mappings":";;;;;;AACA,SAAAA,YAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,WAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAE,WAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,UAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA4F,IAAAG,QAAA,GAG7EA,CAACC,SAAoB,EAAEC,OAAoB,KAAK;EAC7D,OAAO;IACLC,QAAQ,EAAE,IAAAC,iBAAG;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;IACDC,SAAS,EAAE;MACTC,YAAY,EAAE;QACZC,cAAc,EAAE;UACdC,SAAS,EAAEA,CAAA,KAAMN,OAAO,CAACO,MAAM,CAACC,aAAa,CAACC,2BAAc;
|
|
1
|
+
{"version":3,"names":["_graphqlTag","data","require","_workspace","_default","workspace","graphql","typeDefs","gql","resolvers","Subscription","componentAdded","subscribe","pubsub","asyncIterator","ComponentAdded","resolve","payload","componentChanged","ComponentChanged","componentRemoved","ComponentRemoved","Component","status","wsComponent","getStatus","issuesCount","getIssues","count","issues","toObjectWithDataAsString","Workspace","path","ws","name","icon","components","offset","limit","list","getComponent","id","componentID","resolveComponentId","component","get","Query","exports","default"],"sources":["workspace.graphql.ts"],"sourcesContent":["import { GraphqlMain } from '@teambit/graphql';\nimport { gql } from 'graphql-tag';\n\nimport { ComponentAdded, ComponentChanged, ComponentRemoved, Workspace } from './workspace';\nimport { WorkspaceComponent } from './workspace-component';\n\nexport default (workspace: Workspace, graphql: GraphqlMain) => {\n return {\n typeDefs: gql`\n type ModifyInfo {\n # is the component modified.\n hasModifiedFiles: Boolean\n\n # the component has Modified Dependencies\n hasModifiedDependencies: Boolean\n }\n\n type ComponentStatus {\n # component is pending to be tagged automatically.\n modifyInfo: ModifyInfo\n\n # is the new component new.\n isNew: Boolean\n\n # is the component deleted from the workspace.\n isDeleted: Boolean\n\n # is the component staged.\n isStaged: Boolean\n\n # does the component exists in the workspace.\n isInWorkspace: Boolean\n\n # does the component exists in the scope.\n isInScope: Boolean\n\n # does the component is outdated (pending for update).\n isOutdated: Boolean\n }\n\n extend type Component {\n status: ComponentStatus\n }\n\n type Issue {\n type: String!\n description: String!\n solution: String\n data: String\n }\n\n extend type Component {\n # the count of errors in component in workspace\n issuesCount: Int\n issues: [Issue]\n }\n\n type Workspace {\n name: String\n path: String\n icon: String\n components(offset: Int, limit: Int): [Component]\n getComponent(id: String!): Component\n }\n\n type Subscription {\n componentAdded: ComponentAdded\n componentChanged: ComponentChanged\n componentRemoved: ComponentRemoved\n }\n\n type ComponentAdded {\n component: Component\n }\n\n type ComponentChanged {\n component: Component\n }\n\n type ComponentRemoved {\n componentIds: [ComponentID]\n }\n\n type Query {\n workspace: Workspace\n }\n `,\n resolvers: {\n Subscription: {\n componentAdded: {\n subscribe: () => graphql.pubsub.asyncIterator(ComponentAdded),\n resolve: (payload) => payload.componentAdded\n },\n componentChanged: {\n subscribe: () => graphql.pubsub.asyncIterator(ComponentChanged),\n resolve: (payload) => payload.componentChanged,\n },\n componentRemoved: {\n subscribe: () => graphql.pubsub.asyncIterator(ComponentRemoved),\n resolve: (payload) => payload.componentRemoved,\n },\n },\n Component: {\n status: async (wsComponent: WorkspaceComponent) => {\n return wsComponent.getStatus();\n },\n issuesCount: (wsComponent: WorkspaceComponent): number => {\n return wsComponent.getIssues()?.count || 0;\n },\n issues: (wsComponent: WorkspaceComponent) => {\n return wsComponent.getIssues()?.toObjectWithDataAsString();\n },\n },\n Workspace: {\n path: (ws) => ws.path,\n name: (ws) => ws.name,\n icon: (ws) => ws.icon,\n components: async (ws: Workspace, { offset, limit }: { offset: number; limit: number }) => {\n return ws.list({ offset, limit });\n },\n getComponent: async (ws: Workspace, { id }: { id: string }) => {\n try {\n const componentID = await ws.resolveComponentId(id);\n const component = await ws.get(componentID);\n return component;\n } catch {\n return null;\n }\n },\n },\n Query: {\n workspace: () => workspace,\n },\n },\n };\n};\n"],"mappings":";;;;;;AACA,SAAAA,YAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,WAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAE,WAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,UAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA4F,IAAAG,QAAA,GAG7EA,CAACC,SAAoB,EAAEC,OAAoB,KAAK;EAC7D,OAAO;IACLC,QAAQ,EAAE,IAAAC,iBAAG;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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CAAC,KAAK;UACzF,OAAOL,EAAE,CAACM,IAAI,CAAC;YAAEF,MAAM;YAAEC;UAAM,CAAC,CAAC;QACnC,CAAC;QACDE,YAAY,EAAE,MAAAA,CAAOP,EAAa,EAAE;UAAEQ;QAAmB,CAAC,KAAK;UAC7D,IAAI;YACF,MAAMC,WAAW,GAAG,MAAMT,EAAE,CAACU,kBAAkB,CAACF,EAAE,CAAC;YACnD,MAAMG,SAAS,GAAG,MAAMX,EAAE,CAACY,GAAG,CAACH,WAAW,CAAC;YAC3C,OAAOE,SAAS;UAClB,CAAC,CAAC,MAAM;YACN,OAAO,IAAI;UACb;QACF;MACF,CAAC;MACDE,KAAK,EAAE;QACLzC,SAAS,EAAEA,CAAA,KAAMA;MACnB;IACF;EACF,CAAC;AACH,CAAC;AAAA0C,OAAA,CAAAC,OAAA,GAAA5C,QAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/workspace",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.548",
|
|
4
4
|
"homepage": "https://bit.cloud/teambit/workspace/workspace",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.workspace",
|
|
8
8
|
"name": "workspace",
|
|
9
|
-
"version": "1.0.
|
|
9
|
+
"version": "1.0.548"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"lodash": "4.17.21",
|
|
@@ -54,9 +54,9 @@
|
|
|
54
54
|
"@teambit/explorer.ui.gallery.component-grid": "0.0.496",
|
|
55
55
|
"@teambit/scopes.scope-id": "0.0.7",
|
|
56
56
|
"@teambit/workspace.ui.empty-workspace": "0.0.508",
|
|
57
|
-
"@teambit/component": "1.0.
|
|
58
|
-
"@teambit/dependency-resolver": "1.0.
|
|
59
|
-
"@teambit/envs": "1.0.
|
|
57
|
+
"@teambit/component": "1.0.548",
|
|
58
|
+
"@teambit/dependency-resolver": "1.0.548",
|
|
59
|
+
"@teambit/envs": "1.0.548",
|
|
60
60
|
"@teambit/legacy.extension-data": "0.0.36",
|
|
61
61
|
"@teambit/legacy.scope": "0.0.34",
|
|
62
62
|
"@teambit/legacy.consumer-component": "0.0.35",
|
|
@@ -64,29 +64,29 @@
|
|
|
64
64
|
"@teambit/legacy.bit-map": "0.0.91",
|
|
65
65
|
"@teambit/toolbox.fs.last-modified": "0.0.5",
|
|
66
66
|
"@teambit/toolbox.path.path": "0.0.8",
|
|
67
|
-
"@teambit/logger": "0.0.
|
|
68
|
-
"@teambit/objects": "0.0.
|
|
69
|
-
"@teambit/scope": "1.0.
|
|
70
|
-
"@teambit/graph": "1.0.
|
|
71
|
-
"@teambit/cli": "0.0.
|
|
72
|
-
"@teambit/isolator": "1.0.
|
|
73
|
-
"@teambit/component-tree": "1.0.
|
|
67
|
+
"@teambit/logger": "0.0.1218",
|
|
68
|
+
"@teambit/objects": "0.0.55",
|
|
69
|
+
"@teambit/scope": "1.0.548",
|
|
70
|
+
"@teambit/graph": "1.0.548",
|
|
71
|
+
"@teambit/cli": "0.0.1125",
|
|
72
|
+
"@teambit/isolator": "1.0.548",
|
|
73
|
+
"@teambit/component-tree": "1.0.548",
|
|
74
74
|
"@teambit/legacy.constants": "0.0.11",
|
|
75
75
|
"@teambit/harmony.modules.resolved-component": "0.0.502",
|
|
76
76
|
"@teambit/legacy.utils": "0.0.17",
|
|
77
|
-
"@teambit/watcher": "1.0.
|
|
78
|
-
"@teambit/aspect-loader": "1.0.
|
|
79
|
-
"@teambit/config-store": "0.0.
|
|
80
|
-
"@teambit/config": "0.0.
|
|
77
|
+
"@teambit/watcher": "1.0.548",
|
|
78
|
+
"@teambit/aspect-loader": "1.0.548",
|
|
79
|
+
"@teambit/config-store": "0.0.5",
|
|
80
|
+
"@teambit/config": "0.0.1299",
|
|
81
81
|
"@teambit/harmony.modules.requireable-component": "0.0.502",
|
|
82
82
|
"@teambit/toolbox.modules.module-resolver": "0.0.11",
|
|
83
83
|
"@teambit/workspace.modules.node-modules-linker": "0.0.262",
|
|
84
|
-
"@teambit/graphql": "1.0.
|
|
85
|
-
"@teambit/bundler": "1.0.
|
|
86
|
-
"@teambit/global-config": "0.0.
|
|
84
|
+
"@teambit/graphql": "1.0.548",
|
|
85
|
+
"@teambit/bundler": "1.0.548",
|
|
86
|
+
"@teambit/global-config": "0.0.1128",
|
|
87
87
|
"@teambit/legacy.consumer-config": "0.0.34",
|
|
88
|
-
"@teambit/ui": "1.0.
|
|
89
|
-
"@teambit/variants": "0.0.
|
|
88
|
+
"@teambit/ui": "1.0.548",
|
|
89
|
+
"@teambit/variants": "0.0.1392",
|
|
90
90
|
"@teambit/component-issues": "0.0.155",
|
|
91
91
|
"@teambit/component.sources": "0.0.86",
|
|
92
92
|
"@teambit/harmony.modules.in-memory-cache": "0.0.13",
|
|
@@ -100,19 +100,19 @@
|
|
|
100
100
|
"@teambit/lanes.hooks.use-lane-components": "0.0.280",
|
|
101
101
|
"@teambit/lanes.hooks.use-lanes": "0.0.282",
|
|
102
102
|
"@teambit/ui-foundation.ui.side-bar": "0.0.901",
|
|
103
|
-
"@teambit/command-bar": "1.0.
|
|
103
|
+
"@teambit/command-bar": "1.0.548",
|
|
104
104
|
"@teambit/component.ui.component-filters.component-filter-context": "0.0.233",
|
|
105
105
|
"@teambit/component.ui.component-filters.deprecate-filter": "0.0.231",
|
|
106
106
|
"@teambit/component.ui.component-filters.env-filter": "0.0.247",
|
|
107
107
|
"@teambit/component.ui.component-filters.show-main-filter": "0.0.224",
|
|
108
|
-
"@teambit/sidebar": "1.0.
|
|
108
|
+
"@teambit/sidebar": "1.0.548",
|
|
109
109
|
"@teambit/ui-foundation.ui.react-router.slot-router": "0.0.515",
|
|
110
|
-
"@teambit/pubsub": "1.0.
|
|
110
|
+
"@teambit/pubsub": "1.0.548",
|
|
111
111
|
"@teambit/harmony.modules.concurrency": "0.0.12",
|
|
112
112
|
"@teambit/toolbox.promise.map-pool": "0.0.6",
|
|
113
113
|
"@teambit/workspace.ui.use-workspace-mode": "0.0.2",
|
|
114
114
|
"@teambit/component-descriptor": "0.0.432",
|
|
115
|
-
"@teambit/deprecation": "1.0.
|
|
115
|
+
"@teambit/deprecation": "1.0.548",
|
|
116
116
|
"@teambit/ui-foundation.ui.buttons.collapser": "0.0.226",
|
|
117
117
|
"@teambit/workspace.ui.preserve-workspace-mode": "0.0.2",
|
|
118
118
|
"@teambit/cloud.hooks.use-cloud-scopes": "0.0.8",
|
|
@@ -169,7 +169,7 @@ export function useWorkspace(options: UseWorkspaceOptions = {}) {
|
|
|
169
169
|
const unSubCompRemoved = subscribeToMore({
|
|
170
170
|
document: COMPONENT_SUBSCRIPTION_REMOVED,
|
|
171
171
|
updateQuery: (prev, { subscriptionData }) => {
|
|
172
|
-
const idsToRemove: ComponentIdObj[] | undefined = subscriptionData
|
|
172
|
+
const idsToRemove: ComponentIdObj[] | undefined = subscriptionData?.data?.componentRemoved?.componentIds;
|
|
173
173
|
if (!idsToRemove || idsToRemove.length === 0) return prev;
|
|
174
174
|
|
|
175
175
|
// side effect - trigger observers
|