pnp / pnpjs

Fluent JavaScript API for SharePoint and Microsoft Graph REST APIs
https://pnp.github.io/pnpjs/
Other
750 stars 306 forks source link

pnp/config-store not working #2842

Closed necik11 closed 9 months ago

necik11 commented 9 months ago

Major Version

3.x

Minor Version Number

3.20.1

Target environment

SharePoint Framework

Additional environment details

I am using SharePoint Framework. I am trying on local environment + gulp serve so i am using interactive auth.

Expected or Desired Behavior

Load Setting from choosen web.

Observed Behavior

Argument of type 'IWeb & IInvokable' is not assignable to parameter of type 'IWeb'. Type 'IWeb & IInvokable' is missing the following properties from type 'IWeb': createBatch, _update, _forceCaching, toUrlAndQuery, and 19 more.ts(2345)

Steps to Reproduce

From: documentation Getting Started: npm install @pnp/sp @pnp/config-store --save

import { Web } from "@pnp/sp/presets/all";
import { Settings, SPListConfigurationProvider } from "@pnp/config-store";

const w = Web(this.context.pageContext.web.absoluteUrl);
const settings = new Settings();
const provider = new SPListConfigurationProvider(w, "myconfiglistname");
await settings.add("mykey", "myvalue");
await settings.load(provider);

Error on "w":

Argument of type 'IWeb & IInvokable<any>' is not assignable to parameter of type 'IWeb'.
  Type 'IWeb & IInvokable<any>' is missing the following properties from type 'IWeb': createBatch, _update, _forceCaching, toUrlAndQuery, and 19 more.ts(2345)

I need exactly what´s wrote: load application configuration from one or more providers and share it across an application in a consistent way.

I also have a question related to this, wouldn't it be better to use tenant properties : + use the cache from your old solution: https://github.com/SharePoint/PnP-JS-Core/blob/master/src/configuration/pnplibconfig.ts

Anyway, there is bug even in the documentation for getStorageEntity

IStorageEntity no longer belongs to pnp/sp but must be use: import { IStorageEntity } from "@pnp/sp/presets/all"; or import { IStorageEntity } from "@pnp/sp/webs" ;

juliemturner commented 9 months ago

Not sure how it happened but you ended up in the documentation for version 2. You stated above you're using version 3.20.1 so you should start here: https://pnp.github.io/pnpjs/getting-started/

I would also just say that this statement concerns me but may be just the way I'm reading it.

I am trying on local environment + gulp serve so i am using interactive auth.

You can certainly locally gulp serve, but you need to be at least using the hosted SPFx workbench

necik11 commented 9 months ago

Probably because I googled it and it referred me there (sorry for confuse). So in version 3 something like @pnp/config-store no longer exists and I have to do it myself?

Anyway, I've been doing spfx for a while now, so "getting started" isn't necessary :).

And I don't have a problem with running webpart or extensions (CA), but I have a problem with loading the configuration property for multiple sites - I want to load application configuration from one place and share it across an application in a consistent way.

That is why the procedure is described further "tenant properties" which are referenced correctly. And still a bug in the documentation - "IStorageEntity ".

juliemturner commented 9 months ago

Yes, I use tenant properties for that type of thing as well, so I agree that's a good use case. And yes, there might be a bug in the documentation for the import. I'm not exactly clear what you're saying above. Do you need help getting the sample for a tenant property working or are you just saying there's a bug in the docs?

necik11 commented 9 months ago

Thank you for the very quick reply.

getstorageentity: there is this import: import { spfi, SPFx, IStorageEntity } from "@pnp/sp";

But in @pnp/sp is no IStorageEntity.

Like i wrote, there must be import like this: import { IStorageEntity } from "@pnp/sp/presets/all"; or import { IStorageEntity } from "@pnp/sp/webs" ;

juliemturner commented 9 months ago

Ok, sure... looks like a bug in the docs. I can fix it real quick for you.

necik11 commented 9 months ago

Because of such a "little thing" I would not write. My original question was about "config-store", which unfortunately is no longer current (didn't notice I was looking at v2). 🙈 And since I've already taken your time, I wanted to at least point out a liitle mistake in the documentation. thank you very much

github-actions[bot] commented 9 months ago

This issue is locked for inactivity or age. If you have a related issue please open a new issue and reference this one. Closed issues are not tracked.